Arduino Ladder · Bozoma Innovation Hub

Band 1  ·  Signal Tower

Swap  The traffic light module

The same sequence you built by hand, on a module with four wires. Then find the resistors somebody fitted for you.

Time
65 min
You need
Traffic light module, 5 jumper wires
At once
One per traffic light module
Before this
Finish Band 1 Part 6 first. This is a Swap you do after wiring three loose LEDs, never instead of it.

Sketches for this project

Every file opens with a plain-English header saying what it does and how to wire it, hole by hole.

Why

Do this one second, not first

This is a Swap with a condition attached, and the condition matters.

Build the three loose LEDs by hand first. Wire the resistors yourself, get one of them backwards, find out why nothing lit, fix it. Then come here.

The module is four wires and no resistors. It is faster, tidier, and it works first time. All of which makes it a bad way to learn what a resistor is for, and a very good way to find out what a module is once you already know.

The question this build exists to ask

Your hand-wired tower needed three resistors. This module needs none.

So where did they go?

They did not go anywhere. Somebody fitted them, on the board, before it reached you, and charged you for the convenience. Part of this build is going to find them with your eyes.

Build

Five wires, no resistors

20 min
+ − − + j i h g f e d c b a 1 5 10 USB ARDUINO UNO traffic light module traffic light module R R Y Y G G GND GND SCL SCL SDA SDA AREF AREF GND GND 13 13 12 12 11 11 10 10 9 9 8 8 7 7 6 6 5 5 4 4 3 3 2 2 1 1 0 0 IOR IOR RST RST 3V3 3V3 5V 5V GND GND GND GND VIN VIN A0 A0 A1 A1 A2 A2 A3 A3 A4 A4 A5 A5
Four module pins, five wires. This page names no holes on purpose: the only rule is four different columns, one pin per column.
Which rail pairYour board has two + rails and two − rails, one pair along each long edge, and on most boards the two pairs are not joined to each other. On this page, “the rail” always means the pair along the top edge, nearest row j, the same pair Band 1 uses. Put every rail wire on that pair and it works; split them across both and nothing lights, with nothing visibly wrong.
Before you startUSB unplugged. Leave your hand-wired tower on the board if there is room; you will want to compare them. If there is not, photograph it first.

Read your own module before you wire it

The pins are marked on the board itself, next to the header. Look at yours rather than trusting any page, including this one.

Marked R, Y, G and GND

The common kind, and what the sketch assumes. The three colour pins go to Arduino pins and GND goes to the − rail.

→ Wire it as the table says. Nothing to change.

Marked R, Y, G and VCC (or +)

A common-anode module. The fourth pin goes to 5V instead, and the lights come on when the sketch says LOW rather than HIGH.

→ Swap every HIGH and LOW in the sketch. Everything else is identical.

Module pinArduino pinWhich light
R9Red
Y8Yellow
G7Green
GNDthe − railthe shared return path

Then one wire from the − rail to a GND pin, as always. That is five wires in all, or four if you take the module's GND straight to an Arduino GND pin and skip the rail. The hand-wired tower took seven, plus three resistors and three LEDs to place the right way round.

Push the module into the breadboard so its four pins land side by side in four different columns, one pin per column, all at the same row letter. If the pins are on a right-angle header instead, run jumper wires straight to them and skip the breadboard.

You should seeAll four pins firmly in, in four separate columns, and the module sitting so you can read the three lights easily.
Four different columns, not one row of five holesThe five holes running across a column are joined underneath. Push all four pins into one of those and you have joined R, Y, G and GND to each other, which is a short circuit and not a circuit. This is the same “one hole, one leg” rule from Band 1, arriving in a new shape.

Upload b1_05_traffic_module.ino.

You should seeRed for five seconds, red and yellow together for a second and a half, green for five seconds, yellow alone for a second and a half, then round again. Exactly what your hand-wired tower does.
If the colours come out in the wrong orderYour module's pins are labelled differently from the table. Swap the wires at the Arduino end until red is red, then write down which pin ended up being which colour. Nothing is broken.
If nothing lights at allCheck the GND wire first. Then check whether your fourth pin is marked GND or VCC: if it is VCC it goes to 5V, and with it on the − rail the module is simply not powered.
If two lights are on at once, in a pattern that makes no sense, but the rhythm is rightYou have a common-anode module running a common-cathode sketch: every light that should be on is off, and every one that should be off is on. Since two of the three are off in most states, what you see is two lights on. Swap every HIGH and LOW in the sketch and it comes right.
Look closer

Find the resistors

20 min

Turn the module over, or look closely at the front near the lights.

You should seeThree small black rectangles, standing on end or lying flat, one near each light. They have tiny numbers printed on them, often 221, 102 or 101.

Those are your resistors. They were there all along.

Reading a surface-mount resistor

They do not use colour stripes at this size. They use three digits: the first two are the number, and the third says how many zeros to add.

  • 221 means 22 with 1 zero, so 220 ohms. The same value you used by hand.
  • 102 means 10 with 2 zeros, so 1000 ohms. That would make the lights noticeably dimmer.
  • 101 means 10 with 1 zero, so 100 ohms. This one is worth stopping at. With five volts on the pin and about two across a red LED, 100 ohms lets through roughly 30 thousandths of an amp, and an Arduino pin is rated for 20. It works, it is bright, and it is over the line. You would not choose it. Somebody did, to make the module look good on a shelf.

If yours says 101, the module is still safe enough to use for this build, because only one or two lights are on at a time and the pin survives being pushed a little. It is a good example of the difference between works and right, and of what you give up when the choice is made for you. Write it in your log.

Write down what yours say. Then compare your module's brightness with your hand-wired tower's. If the numbers differ, you should be able to see the difference, and you now know exactly why.

Now compare the two sketches

Open b1_05_traffic_module.ino and b1_03_signal_variables.ino side by side. Not b1_02: that is the hard-coded one, and against it almost everything changed.

Answer these in your build log
  1. What actually changed between the two sketches?
  2. Did you learn a new idea to do this build, or point an old one at new hardware?
  3. The module took five wires and no resistors. The tower took seven wires and three resistors. Name one thing you gave up in exchange.
  4. If a module's resistor turned out to be the wrong value for your LEDs, what could you do about it?
Something to check yourself against

1. Look properly, because the answer is stranger than you expect. Nothing changed. Not the pin numbers, not the timings, not the states. b1_05 is b1_03 with the four repeated blocks folded into one showState function called four times, and that tidying has nothing whatever to do with the module. The board could not tell the difference between your tower and this module if it tried, because from the pin's point of view there is no difference: three pins, three lights, one shared return.

2. An old one at new hardware. That is worth noticing, because most of what looks like new learning in electronics turns out to be this.

3. The choice. You cannot pick the resistor, you cannot use a different colour LED, and you cannot move one light somewhere else on the board. A module trades flexibility for speed, and that is a fine trade as long as you make it knowingly.

4. Almost nothing, short of unsoldering it. That is the honest answer, and it is the reason a hand-wired circuit is not simply a worse version of a module.

Change it

Make it yours

25 min
Bronze
Give the module a real crossing's fifth state: a flashing green just before the yellow, three flashes in one second, warning drivers that the light is about to change. You will need more showState calls, not new ideas. Say in your log how many lines you added.
Silver
You need the hand-wired tower back on the board for this. If you took it down for room, rebuild it from your photograph first: that is a fair fifteen minutes, and it is also the last time you will ever wire three LEDs from nothing. Run the module and the tower at the same time, as two crossings on the same road, so that one is red while the other is green. They cannot share a single pin. Look at your tower and write down which three pins it is actually on: if you did Band 1's Bronze task, its yellow light is on pin 12 rather than pin 8. Then move the module to pins 4, 3 and 2, which nothing else uses, change its three wires, and change the three lines at the top of the sketch that name them. Then you need six pin names, not three, and that is the moment naming your variables stops being a style rule and starts being the only way to keep track. Six pins, one sketch, and a real reason for the states to have names.
Gold
Make the yellow light on the module flash three times during the change state without altering how long that state lasts, and do it while the other tower's lights carry on correctly. This is the Band 1 Gold task with something else that must not be interrupted, which is a hint about Band 5.
Done

This does not replace the band's evidence

The module build is a Swap in the sense that it teaches the same sequence, but Band 1's evidence is about the hand-wired tower, because that is where the resistor lesson lives.

Claim Band 1 with your hand-wired tower. Add this one to the same folder as a second piece, with your note about what the module's resistors turned out to be. A facilitator seeing both learns more about what you understood than either alone would tell them.

Ship it

One video under sixty seconds, and one post of five lines. You built something different from the person next to you, so your video is the one nobody else in the room can post. Say in the post which build you chose and why — that choice is itself worth a line.

The four shots: three seconds of the thing still, fifteen of you doing something to it, fifteen of it responding all the way to the end, and ten of your measurement or the thing that went wrong first.

Show your work has the template and the three checks to make before anything goes public. Tag it #BozomaBuilds.