Code:
#include "Arduino.h"
//LCD
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
// DIR und STEP pins definieren
#define dirPin_VL 28
#define stepPin_VL 26
#define dirPin_HL 55
#define stepPin_HL 54
#define dirPin_VR 34
#define stepPin_VR 36
#define dirPin_HR 61
#define stepPin_HR 60
//definiere steps pro umdrehung:
#define stepsPerRevolution 200
//definiere enable pins:
#define enbl_VL 24
#define enbl_HL 38
#define enbl_VR 30
#define enbl_HR 56
void setup()
{
//LCD
lcd.begin(16, 2);
lcd.clear();
lcd.setCursor(0, 0);
lcd.setBacklight(HIGH);
lcd.print("vier Stepper o.L.");
lcd.setCursor(0, 1);
lcd.print("basic example_1");
delay(2000);
lcd.clear();
//pins als output:
pinMode(dirPin_VL, OUTPUT);
pinMode(stepPin_VL, OUTPUT);
pinMode(enbl_VL, OUTPUT);
pinMode(dirPin_HL, OUTPUT);
pinMode(stepPin_HL, OUTPUT);
pinMode(enbl_HL, OUTPUT);
pinMode(dirPin_VR, OUTPUT);
pinMode(stepPin_VR, OUTPUT);
pinMode(enbl_VR, OUTPUT);
pinMode(dirPin_HR, OUTPUT);
pinMode(stepPin_HR, OUTPUT);
pinMode(enbl_HR, OUTPUT);
Serial.begin(115200);
// deaktiviere enable pins:
digitalWrite(enbl_VL, HIGH);
digitalWrite(enbl_HL, HIGH);
digitalWrite(enbl_VR, HIGH);
digitalWrite(enbl_HR, HIGH);
}
void loop()
{
// aktiviere enable pins:
digitalWrite(enbl_VL, LOW);
digitalWrite(enbl_HL, LOW);
digitalWrite(enbl_VR, LOW);
digitalWrite(enbl_HR, LOW);
// drehe alle vier Stepper langsam vorwaerts fünf mal herum:
//set dir pinns vorwarts
digitalWrite(dirPin_VL, LOW);
digitalWrite(dirPin_HL, LOW);
digitalWrite(dirPin_VR, HIGH);
digitalWrite(dirPin_HR, HIGH);
for (int i = 0; i < 5 * stepsPerRevolution; i++)
{
digitalWrite(stepPin_VL, HIGH);
digitalWrite(stepPin_HL, HIGH);
digitalWrite(stepPin_VR, HIGH);
digitalWrite(stepPin_HR, HIGH);
delayMicroseconds(2000);
digitalWrite(stepPin_VL, LOW);
digitalWrite(stepPin_HL, LOW);
digitalWrite(stepPin_VR, LOW);
digitalWrite(stepPin_HR, LOW);
delayMicroseconds(2000);
}
delay(1000);
// drehe alle vier Stepper langsam rückwärts fünf mal herum:
//set dir pinns vorwarts
digitalWrite(dirPin_VL, HIGH);
digitalWrite(dirPin_HL, HIGH);
digitalWrite(dirPin_VR, LOW);
digitalWrite(dirPin_HR, LOW);
for (int i = 0; i < 5 * stepsPerRevolution; i++)
{
digitalWrite(stepPin_VL, HIGH);
digitalWrite(stepPin_HL, HIGH);
digitalWrite(stepPin_VR, HIGH);
digitalWrite(stepPin_HR, HIGH);
delayMicroseconds(2000);
digitalWrite(stepPin_VL, LOW);
digitalWrite(stepPin_HL, LOW);
digitalWrite(stepPin_VR, LOW);
digitalWrite(stepPin_HR, LOW);
delayMicroseconds(2000);
}
delay(1000);
}
EDIT: die spannungen bei X und E1, also Vmot und Vdd sind da...
Lesezeichen