Blinking LED

2.1 Lab: Blinking by Sergio Almendros, Xavier Ramon and Ferran Selva.


We simulated a semaphore for blind people. The procedure is the following:

  1. The semaphore starts with red light.
  2. When someone press the button, semaphore changes to a green light, and the buzzer beeps.
  3. After 8 sec, the semaphore turns to a blinking yellow light, and the buzzer beeps faster. This indicates to the pedestrians that the semaphore is going to change to red.
  4. After 1.25 sec, the semaphore turns red and waits to the next pedestrian

Materials

  1. Arduino UNO
  2. 3 LEDs
  3. 100 KOhms resistor
  4. Button
  5. Speaker

Video

https://www.youtube.com/watch?v=df1ys60HK5s

BreadBoard

Schematic

Code

#define NOTE_C3 131
const int ledRed = 13; 
const int ledYellow = 12;
const int ledGreen = 8;
const int buttonPin = 2;
const int voz = 7;
int buttonState = 0; // variable for reading the pushbutton status
int on = 0;
void setup() {
Serial.begin(9600);
// initialize the LED pin as an output:
pinMode(ledRed , OUTPUT);
pinMode(ledYellow , OUTPUT);
pinMode(ledGreen , OUTPUT);
pinMode(voz , OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);

}
void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
//Serial.print(“Estado del boton”);
//Serial.println(buttonState);
digitalWrite(ledRed, HIGH);

if (buttonState == HIGH) {
delay(500);
digitalWrite(ledRed, LOW);

digitalWrite(ledGreen, HIGH);
int noteDuration = 1000/4;

for(int i=0;i<8;i++){
tone(voz, NOTE_C3,noteDuration);
delay(1000);
}
digitalWrite(ledGreen, LOW);

digitalWrite(ledYellow, HIGH);
tone(voz, NOTE_C3,noteDuration);
delay(250);
for(int i=0;i<5;i++){
digitalWrite(ledYellow, LOW);
delay(250);
digitalWrite(ledYellow, HIGH);
tone(voz, NOTE_C3,noteDuration);
delay(250);
}
digitalWrite(ledYellow, LOW);
}
}

Email me when Wild World of Wireless publishes stories