Program
Motor control with L293D driver
int value = 0; // a variable that contains the value
int motorFowards = 10; // Motor forward - > PIN 10
int motorBackwards = 11; // Motor recoil - > PIN 11
void setup() {} // Not necessary
void loop() {
analogWrite(motorBackwards, 0); // Motor forward... raises the speed
for(value = 0; value <= 255; value+=5) {
analogWrite (motorFowards, value);
delay (30);
}
for(value = 255; value >=0; value-=5) { // forward motor... lowers the speed
analogWrite (motorFowards, value);
delay (30);
}
analogWrite(motorFowards, 0); // Motor back... raises the speed
for(value = 0; value <= 255; value+=5) {
analogWrite (motor motorBackwards, value);
delay (30);
}
for(value = 255; value >=0; value-=5) { // motor backwards... lowers speed }
analogWrite (motorBackwards, value);
delay (30);
}
}
28
28