Traffic Light V1 (without Ultrasonic Sensor Alarm)

by viransh maker in Circuits > Arduino

220 Views, 0 Favorites, 0 Comments

Traffic Light V1 (without Ultrasonic Sensor Alarm)

20220205_103433.jpg

this is a simple traffic light in a few days I will release a more advance version of this which has a ultrasonic sensor

Supplies

1 breadboard

1 Arduino uno r3

1 battery pack (4 batteries)

3 leds (red, yellow, green)

some male to male jumper wires

Paste

20220204_214907.jpg

paste the breadboard on the battery pack with the included adhesive double sided tape and paste the Arduino on the side of the battery pack with some double sided tape also add a switch on the battery pack if it does not include 1 (mine does so I did not put it in the supplies)

Give Power to Your Arduino

20220204_215905.jpg

connect the female wire to a male to mall wire do this for positive and negative poles and then connect positive to vin and negative to any gnd

Connect the Gnd

20220204_220623.jpg
20220204_220823.jpg

this is a simple but crucial step connect the gnd of the Arduino with a negative power rail


Add All Leds

Screenshot 2022-02-05 100931.png

add all leds as shown it the picture then connect their gnd and their positive with pins with pins 2 - red 3- yellow 4- green if you are still confused you can check the image

Enter Code

install Arduino ide and the write this code or download it


[code]

int redLed = 2; // setting the value of redLed as 2.

int yellowLed = 3; // setting the value of yellowLed as 3.

int greenLed = 4;// setting the value of greenLed as 4.


void setup() {

 // put your setup code here, to run once:

pinMode (redLed,OUTPUT);// Defined redLed as output.

pinMode (yellowLed,OUTPUT);// Defined yellowLed as output.

pinMode (greenLed,OUTPUT);// Defined greenLed as output.

}


void loop() {

 // put your main code here, to run repeatedly:

digitalWrite (redLed,HIGH);// Sending a signal to Pin redLed to Light Up.

delay (8000);// Giving a Gap of 8000 Milliseconds, 1 second = 1000 milliseconds.

digitalWrite (redLed,LOW);

digitalWrite (yellowLed,HIGH);

delay(3000);

digitalWrite(yellowLed,LOW);

digitalWrite(greenLed,HIGH);

delay(4000);

digitalWrite(greenLed,LOW);

}

[/code]