41 lines
648 B
C++
Executable File
41 lines
648 B
C++
Executable File
int motor1 = 6;
|
|
int motor2 = 7;
|
|
boolean sentido = true;
|
|
int espera = 500;
|
|
|
|
void setup() {
|
|
pinMode(motor1, OUTPUT);
|
|
pinMode(motor2, OUTPUT);
|
|
}
|
|
|
|
void giro() {
|
|
if(sentido) {
|
|
digitalWrite(motor2, LOW);
|
|
digitalWrite(motor1, HIGH);
|
|
} else if(!sentido) {
|
|
digitalWrite(motor1, LOW);
|
|
digitalWrite(motor2, HIGH);
|
|
} else {
|
|
digitalWrite(motor1, LOW);
|
|
digitalWrite(motor2, LOW);
|
|
}
|
|
}
|
|
|
|
void detener() {
|
|
digitalWrite(motor1, LOW);
|
|
digitalWrite(motor2, LOW);
|
|
}
|
|
|
|
void loop() {
|
|
detener();
|
|
delay(espera);
|
|
sentido = true;
|
|
giro();
|
|
delay(5000);
|
|
detener();
|
|
delay(espera);
|
|
sentido = false;
|
|
giro();
|
|
delay(5000);
|
|
}
|