Hola a todos, tengo un problema con un proyecto de unas barreras con leds para una maqueta de tren, después de recopilar varios programas por la red y adaptarlos a mi proyecto, soy incapaz de hacer funcionar correctamente los leds, en cuanto alimento el nano, funcionan los leds siempre, independientemente del servo.
Mi idea es que empiecen a funcionar en cuanto se active el pulsador y dejen de funcionar cuando el servo haya vuelto a su posición inicial, que hago mal?
Gracias
// LEDS PARPADEAN SIEMPRE REVISAR
#include <VarSpeedServo.h>
int button1 = 3; //button pin, connect to ground to move servo
int press1 = 0;
VarSpeedServo servo1;
const int servoPin1 = 9;
void setup()
{
servo1.attach(9);
pinMode(button1, INPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
digitalWrite(3, HIGH); //enable pullups to make pin high
}
void loop()
{
press1 = digitalRead(button1);
digitalWrite(12, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(12, LOW); // turn the LED off by making the voltage LOW
delay(100); // wait for a second
digitalWrite(11, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(11, LOW); // turn the LED off by making the voltage LOW
delay(100); // wait for a second
servo1.write(500,5); // GRADOS GIRO, VELOCIDAD
if
(press1 == LOW); //CAMBIA SENTIDO DE GIRO SERVO
else
{
servo1.write(80,5);
}
}