For this project you will need :
-Arduino Uno
-Some jumper wires
-breadboard
-Servo motor
-Green and red LED
This is the arduino code:
#include <Servo.h>
Servo myservo;
void setup ()
{
myservo.attach(9);
pinMode (6,0);
pinMode (5,0);
pinMode (7,1);
pinMode (8,1);
}
void loop ()
{
myservo.writeMicroseconds(100);
delay(500);
if (digitalRead(5)==0)
{
digitalWrite(8,0);
digitalWrite(7,1);
myservo.writeMicroseconds(3000);
delay(2000);
}
else
{
digitalWrite(7,0);
digitalWrite(8,1);
}
if (digitalRead(6)==0)
{
myservo.writeMicroseconds(3000);
delay(2000);
digitalWrite(8,1);
}
else
{
myservo.writeMicroseconds(0);
delay(0);
}}