Some of my son’s other interests include traffic lights (or stop lights), boom barriers, automatic doors and control panels of any kind. The first microcontroller project we decided to build was a traffic light system including a pedestrian crossing. The microcontroller kit I decided to use for this was the PICAXE-20M Starter Pack (USB) which uses a PICAXE 20M with 8 input pins, 8 output pins, 220 lines of program memory and supports interrupts, digital temperature sensors, radio-control servos, keyboard input, user defined musical tunes, infra-red transmission and reception, an 8/10 bit ADC option, pwm motor control and input pulse counting. The device is programmed via the supplied USB cable. It is a surprisingly sophisticated chip for 2,35 euros. Below is an image of the 20M connected to a small breadboard with three LEDs (one red, one yellow, one green) and 330 ohm resistors.

PICAXE 20M Traffic Light Project

In the circuit above, we connected output pin1 to a 330 ohm resistor and then a red LED, output pin2 to a 330 ohm resistor and then a yellow LED and finally output pin3 to a 330 ohm resistor and then a green LED. To program the PICAXE, you will need a copy of the MacAXEPad for the Apple Mac or AXEPad for the PC which is available at the PICAXE software download page. There is also a comprehensive set of manuals online which describe how to develop code for the PICAXE in BASIC. The basic program below controls the traffic light and is my son’s first ever piece of code. :-)

tlight:
high 1
pause 3000
high 2
pause 1000
low 1
low 2
high 3
pause 3000
low 3
high 2
pause 1000
low 2
goto tlight