Servomotor con leds ARDUINO
#include <Servo.h>
Servo myservo;
int buttonPin = 4;
int buttonState = 0;
int ledrojo = 3;
int ledazul = 5;
void setup() {
myservo.attach(2);
pinMode(buttonPin, INPUT);
}
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH){
myservo.write (90);
delay(1000);
digitalWrite(ledrojo,HIGH);
digitalWrite (ledazul, LOW);
}
else{ (buttonState == LOW);
myservo.write (0);
delay(1000);
digitalWrite (ledazul,HIGH);
digitalWrite(ledrojo, LOW);
}
}
Comentarios
Publicar un comentario