// 2846599 DESARROLLO DE SISTEMAS ELECTRONICOS INDUSTRIALES
// SHMUEL OTAVARO
// SERVO Y ARDUINO GIRAR 180 DER Y 0 IZQ
#include <Servo.h>
Servo servo1;
Servo servo2;
int servopin1 = 9;
int servopin2 = 10;
int angulo1 = 90;
int angulo2 = 90;
int buttonPin1 = 7;
int buttonPin2 = 6;
int buttonPin3 = 5;
int buttonPin4 = 4;
void setup() {
servo1.attach(servopin1);
servo2.attach(servopin2);
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);
pinMode(buttonPin4, INPUT);
servo1.write(angulo1);
servo2.write(angulo2);
}
void loop() {
int buttonState1 = digitalRead(buttonPin1);
int buttonState2 = digitalRead(buttonPin2);
int buttonState3 = digitalRead(buttonPin3);
int buttonState4 = digitalRead(buttonPin4);
if (buttonState1 == HIGH) {
angulo1++;
if (angulo1 > 180) {
angulo1 = 180;
}
servo1.write(angulo1);
delay(10);
}
if (buttonState2 == HIGH) {
angulo1--;
if (angulo1 < 0) {
angulo1 = 0;
}
servo1.write(angulo1);
delay(10);
}
if (buttonState3 == HIGH) {
angulo2++;
if (angulo2 > 180) {
angulo2 = 180;
}
servo2.write(angulo2);
delay(10);
}
if (buttonState4 == HIGH) {
angulo2--;
if (angulo2 < 0) {
angulo2 = 0;
}
servo2.write(angulo2);
delay(10);
}
}