const int stepPinX = 2;
const int dirPinX = 5;
const int stepPinY = 7;
const int dirPinY = 6;
const int stepPinZ = 4;
const int dirPinZ = 3;
const int stepsPerRev = 20;
int pulseWidthMicros = 100; // microseconds
int millisBtwnSteps = 100;
void setup() {
Serial.begin(9600);
pinMode(stepPinX, OUTPUT);
pinMode(dirPinX, OUTPUT);
pinMode(stepPinY, OUTPUT);
pinMode(dirPinY, OUTPUT);
pinMode(stepPinZ, OUTPUT);
pinMode(dirPinZ, OUTPUT);
Serial.println(F("Initialisé"));
}
void loop() {
Serial.println();
Serial.println("Marche avant");
digitalWrite(dirPinX, HIGH); // Enables the motor to move in a particular direction
// Makes 200 pulses for making one full cycle rotation
digitalWrite(dirPinY, HIGH);
digitalWrite(dirPinZ, HIGH);
Serial.println("Moteur X");
for (int i = 0; i < stepsPerRev; i++) {
digitalWrite(stepPinX, HIGH);
delayMicroseconds(pulseWidthMicros);
digitalWrite(stepPinX, LOW);
delayMicroseconds(millisBtwnSteps);
Serial.print(i);
delay(150);
}
Serial.println();
Serial.println("Moteur Y");
for (int j = 0; j < stepsPerRev; j++) {
digitalWrite(stepPinY, HIGH);
delayMicroseconds(pulseWidthMicros);
digitalWrite(stepPinY, LOW);
delayMicroseconds(millisBtwnSteps);
Serial.print(j);
delay(150);
}
Serial.println();
Serial.println("Moteur Z");
for (int k = 0; k < stepsPerRev; k++) {
digitalWrite(stepPinZ, HIGH);
delayMicroseconds(pulseWidthMicros);
digitalWrite(stepPinZ, LOW);
delayMicroseconds(millisBtwnSteps);
Serial.print(k);
delay(150);
}
delay(1000); // One second delay
Serial.println();
Serial.println();
Serial.println("Marche arrière");
digitalWrite(dirPinX, LOW); //Changes the rotations direction
digitalWrite(dirPinY, LOW);
digitalWrite(dirPinZ, LOW);
Serial.println("Moteur X");
// Makes 400 pulses for making two full cycle rotation
for (int i = 0; i < stepsPerRev; i++) {
digitalWrite(stepPinX, HIGH);
delayMicroseconds(pulseWidthMicros);
digitalWrite(stepPinX, LOW);
delayMicroseconds(millisBtwnSteps);
Serial.print(i);
delay(150);
}
Serial.println();
Serial.println("Moteur Y");
for (int j = 0; j < stepsPerRev; j++) {
digitalWrite(stepPinY, HIGH);
delayMicroseconds(pulseWidthMicros);
digitalWrite(stepPinY, LOW);
delayMicroseconds(millisBtwnSteps);
Serial.print(j);
delay(150);
}
Serial.println();
Serial.println("Moteur Z");
for (int k = 0; k < stepsPerRev; k++) {
digitalWrite(stepPinZ, HIGH);
delayMicroseconds(pulseWidthMicros);
digitalWrite(stepPinZ, LOW);
delayMicroseconds(millisBtwnSteps);
Serial.print(k);
delay(150);
}
delay(1000);
}
uno:A5.2
uno:A4.2
uno:AREF
uno:GND.1
uno:13
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:1
uno:0
uno:IOREF
uno:RESET
uno:3.3V
uno:5V
uno:GND.2
uno:GND.3
uno:VIN
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
stepper1:A-
stepper1:A+
stepper1:B+
stepper1:B-
drv1:ENABLE
drv1:MS1
drv1:MS2
drv1:MS3
drv1:RESET
drv1:SLEEP
drv1:STEP
drv1:DIR
drv1:GND.1
drv1:VDD
drv1:1B
drv1:1A
drv1:2A
drv1:2B
drv1:GND.2
drv1:VMOT
vcc1:VCC
gnd1:GND
stepper2:A-
stepper2:A+
stepper2:B+
stepper2:B-
stepper3:A-
stepper3:A+
stepper3:B+
stepper3:B-
drv2:ENABLE
drv2:MS1
drv2:MS2
drv2:MS3
drv2:RESET
drv2:SLEEP
drv2:STEP
drv2:DIR
drv2:GND.1
drv2:VDD
drv2:1B
drv2:1A
drv2:2A
drv2:2B
drv2:GND.2
drv2:VMOT
drv3:ENABLE
drv3:MS1
drv3:MS2
drv3:MS3
drv3:RESET
drv3:SLEEP
drv3:STEP
drv3:DIR
drv3:GND.1
drv3:VDD
drv3:1B
drv3:1A
drv3:2A
drv3:2B
drv3:GND.2
drv3:VMOT
r1:1
r1:2
r2:1
r2:2
r3:1
r3:2
btn1:1.l
btn1:2.l
btn1:1.r
btn1:2.r
btn2:1.l
btn2:2.l
btn2:1.r
btn2:2.r
btn3:1.l
btn3:2.l
btn3:1.r
btn3:2.r
r4:1
r4:2
r5:1
r5:2
r6:1
r6:2
btn4:1.l
btn4:2.l
btn4:1.r
btn4:2.r
btn5:1.l
btn5:2.l
btn5:1.r
btn5:2.r
btn6:1.l
btn6:2.l
btn6:1.r
btn6:2.r
vcc2:VCC
led1:A
led1:C
led2:A
led2:C
r7:1
r7:2
r8:1
r8:2