You are here

Traffic Light

Eindresultaat

On Sunday morning, when I take my kids to the bakery, we have to pass a crossroads with traffic lights. Around two and a half years of age, my daughter started to show a keen interest in the colors of the light, and the associated actions you could or could not do: "It's red, we have to stop!", "It's green, we don't have to stop!". A year later, she still does that; I thought it was about time to give them a small version that they can play with. If they use it to practice traffic at home, that would be a nice bonus! It also looked like a neat challenge to learn some electronics, and to make it look OK.

There are two challenges to be met: the electronics (led arrays and timing logic) and the case.

Electronics

The end goal is a 3-colored light. The main difficulty here is that the orange light has a much shorter on-time than the red and the green ones. I couldn't think of an easy way to make this work using a 555 timer or similar. In the end I approached it in a different way: I focused on the sequence. I decided to start from a decade counter (CD4017) and wire it up for 4 steps, where the first three each drive a color (marked with L1 … L3 in the schematic), and the fourth triggers reset so that the sequence starts over.

In addition to driving a light, each step also charges an RC circuit. While the RC circuit charges, the voltage at the junction between R and C rises. When it reaches a certain level, the voltage will be high enough to trigger the decade counter to go to the next step. The time between starting to charge the RC circuit, and reaching the trigger voltage for the decade counter can be adjusted by changing the C in the RC circuit, and this allows us to use different timings for red/green on the one hand and orange on the other hand.

The basic circuit outlined above will not work well, because the RC circuits will discharge at about the same rate as they charge, which means that after 3 cycles, when the first step is enabled again, its RC circuit will have some charge left in it. This causes it to charge faster, which messes up the timing later on. After a few cycles, the sequence will stop because the decade counter is not triggered any more. As a solution, I included for each RC circuit a transistor that will discharge the RC circuit of the previous step (Q1 … Q3). This makes sure that at each step, the RC circuit starts charging from an "empty" state.

Another issue is that the decade counter's output current is limited. In order to drive a led array, we have to use a transistor to switch a larger current. In our case, we use a simple BC547 to drive an array of 9 LEDs. (Actually, in this case it might just work without a transistor to drive the LEDs, since they don't consume much current. I didn't check the 4017's data sheet, nor did I do the maths on the LED array current...) In the schematic below, the arrangement of the LED array is shown; this part is built 3 times, one for each colour.

The picture below shows the schematics.

  • IC: CD4017 decade counter
  • R1, R2, R3: 1M
  • R4, R5, R6: 10K
  • R7, R8, R9, R10, R11, R12: 1K
  • D1, D2, D3: 1N4148
  • C1, C3: 22uF
  • C2: 2,2uF

verkeerslicht schema

The schematics were executed on 2 "experiment" PCBs: one for the timing logic, and one for the 3 LED arrays.

Case

The case was my first project using a laser cutter. This meant that, rather than woodworking tools, the tool of choice was Inkscape. The cool thing with a laser cutter is that you can simply draw your design in a 2D vector drawing program, and the laser cutter software will work out what and where to cut. Of course, you can only cut relatively thin board material with it, but if that is what you need, there is no more need for sawing and drilling.

The final design looks like this. It has all the necessary parts (well, almost all) in a 20cm x 30cm area, ready for cutting. During final assembly, I ended up using 5 or 6 of the smallest bits from a previous cut to create the battery holder. The Inkscape SVG can be downloaded here: front 2.svg.

front 2

As you can see, the design for the front panel already included mounting holes for the power switch, so that no drilling was necessary either. I forgot the holes for mounting the front, so I had to drill them afterwards. Of course, drilling manually is a lot less accurate, so I should have included them from the start.

After cutting out the elements, we have a bunch of cut-up plywood that smells like a wood stove:

Vers uit de lasersnijder

After sanding away most of the black edges, we can start gluing the pieces together: the box, the front panel, the battery holder, and the lips that will hold the front panel:

Doosje in elkaar lijmen Front in elkaar lijmen
Batterijvak Lipjes om het front te monteren

This is the fully assembled box:

Doosje klaar

Installing the electronics was easy: the LEDs are press-fit into their holes, and they hold the 2 PCBs in place. The power switch is bolted on using 2 small 2mm bolts; the switch already had threaded holes that accept the bolts, so no nuts were needed. The battery is installed in the battery holder at the bottom of the box:

Elektronica geïnstalleerd

The end result looks like this:

Eindresultaat