dorsafarzam
Published

Sound alert traffic-light

3 colorful LEDs would act out like a traffic-light and a buzzer would turn on when the green LED gets activated.

BeginnerProtip1,250
Sound alert traffic-light

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Resistor 220 ohm
Resistor 220 ohm
×3
LED (generic)
LED (generic)
×3
Breadboard (generic)
Breadboard (generic)
×1
Buzzer
Buzzer
×1
USB-A to B Cable
USB-A to B Cable
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Here's a video of how it works!

Code

traffic-light with buzzer

Arduino
/*created by:Dorsa Farzam. in this project we will tur-on and off 3 LED's consequently and when the third LED is on    
 the buzzer will start to beep for 500ms and then it will tur off for another 500 ms. this will happen repeatedly.
 *  this experiment has been operated on the ARDUINO-UNO R3 board.
 *  this experiment has also been simulated with  Proteus software */
 
 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 outpout
  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 buzeer 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

}

Credits

dorsafarzam
1 project • 0 followers

Comments