Introduction: ATtiny85 Toy Traffic Light

About: I am a sound designer who's studied computer game development, run my own sound design business and like to build thing in my spare time.

This is a toy traffic light i made for a friends son! Using only a few parts and an ATtiny85!

Step 1: Materials

Materials used:

3 LED's (red, yellow and green).

3 Resistors.

3 AA batteries.

1 3 AA battery holder.

1 Switch.

1 ATtiny85.

1 8 pin dip socket.

1 Small piece of bread board.

1 Arduino Leonardo (doesn't have to be a Leonardo).

1 Breadboard and jumpers.

A few pieces of wood

1 inch dowel

Tools used:

Basic woodworking tools.

Wirecutter/stripper.

Soldering iron.

Hot glue gun.

Spray paint.

Step 2: Breadboard

This is the circuit on a breadboard. Always test your circuit on a breadboard before you build it!

I used 65 Ohm resistors. Your circuit might require another resistor value so use Ohm's law to calculate your resistor value.

To learn how to program the ATtiny85 and upload your sketch, check out: http://dev.mikamai.com/post/78652180658/how-to-program-an-attiny85-or-attiny45-with-an

I used an Arduino Leonardo for this.

Step 3: Code

I am not a programmer so this is really basic stuff. There might be a better way of doing it. Please comment if you have any suggestions or improvements!

I don't know if traffic light signals are the same over the world, but here in Sweden it goes like this: Red, Red AND Yellow, Green, Yellow, and back to Red.

The code just cycles through the LEDs forever (or until turned off).

This is the final code I uploaded to the ATtiny85 so the pinmodes described here are for the ATtiny85 since it only has 5 outputs.

//Traffic light toy sketch for ATtiny85. by: Simon Nordberg.

void setup() {

pinMode(0, OUTPUT); //Red LED.

pinMode(1, OUTPUT); //Yellow LED.

pinMode(2, OUTPUT); //Green LED. }

//Looping forever

void loop() {

digitalWrite(0, HIGH); // Turn on red LED.

delay(3000); //Waits for 3 sec.

digitalWrite(1, HIGH); //Turn on yellow LED.

delay(2000); //Waits for 2 sec.

digitalWrite(0, LOW); //Turn off red LED.

digitalWrite(1, LOW); //Turn off yellow LED.

digitalWrite(2, HIGH); //Turn on green LED.

delay(5000); //Waits for 5 sec.

digitalWrite(2, LOW); //Turn off green LED.

digitalWrite(1, HIGH); //Turn on yellow LED.

delay(2000); //Waits for 2 sec.

digitalWrite(1, LOW); //Turn off yellow LED.

}

Step 4: Building

Base: Drill out the base and carve out enough room the fit the batteries, circuit and the switch.


Pole: Drill a hole through the dowel to fit the LED wires through.

Head: Drill 3 holes in the head to fit the LEDs. Drill a hole through the bottom of the head and insert the LEDs from the bottom.

Assembly: Glue the head to the pole and the pole the the base. Before attaching the batteries, Solder the wires to the circuit board.

With a bit of planning, all this fits together nicely! :)

Step 5: You're Done!

That's it! Enjoy building your toy traffic light!

Automation Contest

Participated in the
Automation Contest