Traffic light module
A red, a yellow and a green LED in a row on a small board, each with its own resistor, and four pins. Aliases: traffic light LED module.
It is the first build in a lot of kits: three LEDs that need no breadboard and no
resistors of their own, because the resistors are on the board. Each LED's anode
comes out on its own pin through its resistor, and the three cathodes share GND.
Pins
| Pin | What it does |
|---|---|
R |
The red LED: high lights it. |
Y |
The yellow LED. |
G |
The green LED. |
GND |
The three cathodes. Wire it to the board's ground. |
Properties
resistor is each LED's resistor on the board, 220 ohm by default. The boards are
sold without a schematic, so the value is an assumption; on 5 V it puts about 15 mA
through each LED, as an led on 220 ohm does.
While it runs
Nothing to drag. A lamp lights when its pin is high, and a pin driven with
analogWrite() dims its lamp, as the eye would see it.
What the model gets right
The LEDs. Each is the same diode as the led part, in its own color, so red,
yellow and green light at the currents a real LED does on the same resistor.
The common ground. All three cathodes meet at GND; with it unwired nothing
lights.
What it does not model
The exact resistor on your board, and the LEDs' brightness against each other (a real green LED often looks brighter than the red at the same current).
Common mistakes
Forgetting GND. The module has no other way back.
Adding resistors of your own. They are already on the board; another one in series just dims the LED.
See it in action
Crosswalk runs a traffic light with a push-button crossing and a beeping walk signal. Open it at /templates.