Buzzing Traffic Light

Buzzing Traffic Light

We have identified a problem with school crossing outside popular high schools. Too often, teachers can be unavailable for crossing duties, leaving many crossings in anarchy. Cars are often backed up for the entire road, because people can’t wait for cars to pass. Our solution is to create a buzzing traffic light to help people know when to cross.

 

Required material:

9x Wires

3x Resistors

3x LEDs (1x Red, 1x Yellow, 1x Green)

Step 1

Step 1

Steps:

  1. Connect the first wire to GND (Ground), then connect the other side to a resistor.
  2. Connect a wire from the other side of the resistor to the short LED prong of your choosing (red for example).
  3. Connect a wire from the long prong of the LED to either D2, D4, D5. (D2 for Red, D4 for Yellow, and D5 for Green).
  4. For the other LEDs, repeat the same process
  5. Use this code:

int red = 2;

int yellow = 4;

int green = 5;

int buzzerPin = 3;

void setup()

{

pinMode(red, OUTPUT);

pinMode(yellow, OUTPUT);

pinMode(green, OUTPUT);

pinMode(buzzerPin, OUTPUT);

}



void loop()

{

tone(buzzerPin, 750, 5999);

delay(1);

digitalWrite(green, HIGH);

delay(6000);

tone(buzzerPin, 700, 4999);

delay(1);

digitalWrite(green, LOW);

digitalWrite(yellow, HIGH);

delay(5000);

tone(buzzerPin, 650, 11999);

delay(1);

digitalWrite(yellow, LOW);

digitalWrite(red, HIGH);

delay(12000);

digitalWrite(red, LOW);

}

 

 

 

Add a comment