Hello there!
This is the first project that I am uploading on my Project Hub page. In this project I have made a traffic-light with 3 LEDs and a buzzer. The buzzer has been used for giving the pedestrians an alert that cars are now on the move!. So when the green LED turns-on the buzzer will start to beep and as soon as the green LED turns-off the buzzer will also stop beeping. As many of you have probably noticed, one of the usages of this project is on streets intersection for people with vision disability.
Here are the things we need:
- ARDUINO-UNO R3
- USB 2.0 Cable Type A/B (for uploading the code)
- 3 colorful LEDs(Red, Yellow, Green)
- 3 Resistors(220 ohm)
- Buzzer
- Breadboard
- some jumper wires
So now let's make it!
Here are the schematics of how it works!
So, because we need 4 grounds in here and we only have 3 on the Arduino board, I made a common ground for all of them so that I don't get short of grounds!
As it is shown in the first picture, I have marked some positive and negative signs on my bread-board. Use a jumper wire and connect one side of it to the GND pin of your Arduino board and connect the other side to the negative mark on your bread-board. and from here connect the negative leg of your LEDs to the common ground of your bread-board. Oh by the way, you need to connect the positive leg of the LEDs to the 220 ohm resistor.
So now we are done with the electronic part! Now all you have to do is to upload the code.
const int ledRed= 7;// led is connected to pin 7
const int ledYellow=4;// led is connected to pin 4
const int ledGreen=2;// led is connected to pin 2
const int buzzer=8;// Buzzer is connected to pin 8
void setup() {
pinMode(ledRed,OUTPUT); // the led is used as an output
pinMode(ledYellow,OUTPUT);// the led is used as an output
pinMode(ledGreen,OUTPUT);// the led is used as an output
pinMode(buzzer,OUTPUT);// the Buzzer is used as an output
}
void loop() {
digitalWrite(ledRed,HIGH); // access the voltage to the ledRed
digitalWrite(ledYellow,LOW);//ledYellow is off
digitalWrite(ledGreen,LOW);//ledGreen is off
delay(5000); // wait for 5000ms
digitalWrite(ledRed,LOW); // ledR is off
digitalWrite(ledGreen,LOW);//ledG is off
digitalWrite(ledYellow,HIGH);// ledY is on
delay(2000); // wait for 2000ms
digitalWrite(ledRed,LOW);// ledR is off
digitalWrite(ledYellow,LOW);// ledY is off
digitalWrite(ledGreen,HIGH);// led green is on
delay(4000);// wait for 4000 ms
digitalWrite(buzzer,HIGH);// the buzzer is on
delay(500);// the buzzer will beep for 500ms
digitalWrite(buzzer,LOW);//the buzzer is off now
delay(500);// wait for 500ms
digitalWrite(buzzer,HIGH);// the buzzer is on again
delay(500);// wait for 500ms
digitalWrite(buzzer,LOW);// the buzzer is off now
}


_ztBMuBhMHo.jpg?auto=compress%2Cformat&w=48&h=48&fit=fill&bg=ffffff)









Comments