Arduino: Traffic ligths

I’m starting a new course in HAAGA-HELIA called Building a prototype (Prototyypin rakentaminen). I will blog every homework and all projects I do to my blog. First assignment was to build any little setup with LED ligths and some logic in Arduino. I decided to build traffic ligths. There are separate lights for cars and pedestrians.

Tools and components:

Components:

Arduino UNO 3.0 (basicly any Arduino fits)

USB-cable

2 green leds

2 red leds

1 yellow led

several jumper wires (I used 12)

5 resistors (220 Ω)

Tools:

I used Arduino IDE for coding and to insert my codes to arduino.

For sketch of the breadboard / arduino cabling, I used Fritzing.

Using the tools:

Arduino IDE:

1. Install Arduino IDE. I’m using Windows 64-bit OS, so it was basicly next next next finish installation.

2. Open Arduino IDE.

3. Open up any example (I prefer Blink, or as you may call it, Hello World) to test that your Arduino works.

4. Plug arduino in and press Upload button on the top of the software.

If it doesn’t work, try changing Serial Port from Tools / Serial Port.

Fritzing (optional):

It is adviced to have atleast hand written sketch of your setup. I’m using Fritzing for this.

1. Install, again next next finish.

2. Open up

3. Basicly drag and drop, really easy to use.

4. When board sketch is ready, export image as PNG.

Results, code and cabling

Here is result in video:

Here is the code:

int redcar = 11;
int yellowcar = 12;
int greencar = 13;
int greenped = 10;
int redped = 9;

void setup() {                
  pinMode(redcar, OUTPUT);  
  pinMode(yellowcar, OUTPUT);  
  pinMode(greencar, OUTPUT); 
  pinMode(greenped, OUTPUT); 
  pinMode(redped, OUTPUT);  
}

void loop() {
  digitalWrite(redcar, HIGH);
  digitalWrite(greenped, HIGH);
  delay(10000);
  digitalWrite(yellowcar, HIGH);
  digitalWrite(greenped, LOW);
  digitalWrite(redped, HIGH);
  delay(2000);
  digitalWrite(yellowcar, LOW);
  digitalWrite(redcar, LOW);
  digitalWrite(greencar, HIGH);
  delay(10000);
  digitalWrite(greencar, LOW);
  digitalWrite(yellowcar, HIGH);
  delay(2000);
  digitalWrite(yellowcar, LOW);
  digitalWrite(redped, LOW);

}

And here is the cabling (Fritzing had only red leds, or atleast I didn’t find any other colors :D):

liikennevalot_board

Info:

Computer:

P8-P67 Rev 3.0 motherboard, AMD 6970 HD 2gb grapich card, Intel I5-2500k 6mb cache 4,5 ghz processor, 8gb 1950mhz RAM, and other important components.

Operating System:

Windows 7 64-bit Professional, Service Pack 1

Resources:


Leave a comment