Hi Coders,
I am totally new to arduino and to this forum, I am from class 8 looking for a project for my expo. I had this idea of automatic barrier integrated to traffic lights.
This is the idea poped on my head and i am looking for experts help to complete my code.
-
automatic traffic light system , where the R Y G LEDs goes on and off on the timing fixed
-
Now i wanted to upgrade with barrier system
-
when green is high i want the servo to rotate from say 0' to 120'(technically to be a stop gate) - R and Y low
-
when yellow is high the servo has to move slowly from 120' to 0' - R and G low
-
once it reaches to 0' the RED LED has to be high, rest all LED should be low
Please help me at the earliest.I have written the simple code traffic light but need support to complete as per my idea.
void setup() {
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
}
void loop()
{
{
digitalWrite(8, HIGH); // Turns LED on pin 13 on
delay(2500); // LED on pin 13 remains on for 5 seconds
digitalWrite(8, LOW); // Turns LED on pin 13 off
delay(0);}
digitalWrite(9, HIGH); // Turns LED on pin 12 on
delay(2500); // LED on pin 12 remains on for 5 seconds
digitalWrite(9, LOW); // Turns LED on pin 12 off
delay(0);
digitalWrite(10, HIGH); // Turns LED on pin 11 on
delay(2500); // LED on pin 11 remains on for 5 seconds
digitalWrite(10, LOW); // Turns LED on pin 11 off
delay(0);
}