Source: https://mokxi.com/parts/trafficlight
Updated: 2026-11-19

Part

# Traffic light module

Red, yellow and green LEDs with their resistors on a little board: a pin high lights each.

See every part

- 4 pins
- 1 setting
- In 7 projects
- In 2 lessons

Drawn live by the editor's own code, at the size you see it.

At a glance

## The Traffic light module in brief

What it is, and every setting the properties panel gives it.

The traffic light module is a red, a yellow and a green LED in a row on a small board, each with its own resistor, and four pins: R, Y, G and GND. It is the first build in a lot of kits because it needs no breadboard and no resistors of your own: each anode comes out on its own pin through the board’s resistor and the three cathodes share GND. A pin driven high lights its lamp and a pin driven with analogWrite() dims it. The model gives each LED the same diode as the plain LED part, in its own color, with a 220 ohm resistor by default, which is about 15 mA on 5 V. The exact resistors on your board and the relative brightness of the colors are not modeled.

Family

Outputs

Pins

4

resistor

220

Pins

## 4 pins

Named as the editor names them, so a wire lands where you expect it.

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.

How to use it

## How to wire a traffic light module to an Arduino

Four wires and nothing else. GND goes to the Uno’s GND, and R, Y and G go to three digital pins: the breathalyzer project uses 4 for red, 3 for yellow and 2 for green. The resistors are already on the board, so the pins connect straight to it. A pin that is HIGH lights its lamp.

In the project the module shows the alcohol level on its three lamps, beside an MQ-3 sensor and a 16x2 LCD. The lamp code is only pinMode() and digitalWrite(), so the module is also the easiest way to learn them: set the three pins as outputs, then turn one on at a time.

Part pin

Board pin

R

Pin 4

Y

Pin 3

G

Pin 2

GND

GND

On a 3.3 V board the LEDs get less current through the same resistor, so the lamps are a little dimmer. The wiring is the same on every board.

Click to open it in the editor

This is the simulator itself, running here. Click anything to open it in the editor.

Open this project in the editor Read the full tutorial

The three lamps, as the breathalyzer sets them up

Common errors

## Common Traffic light module errors and fixes

What goes wrong

The fix

No lamp lights at all.

GND is not wired. The three cathodes meet at GND and the module has no other way back, so with it open nothing lights.

The lamps are dim.

You put a resistor of your own in series. The resistors are already on the board, and a second one in series just dims the LED.

The wrong lamp lights for a pin.

The labels are by color: R is red, Y is yellow, G is green. Check which pin each of them is wired to in your sketch.

Questions

## Questions and answers

### Does a traffic light LED module need resistors?

No. Each LED has its own resistor on the board, 220 ohm by default in the model, so the pins go straight to the Arduino.

### How do you dim a lamp on the traffic light module?

Drive its pin with analogWrite() on a PWM pin. The lamp dims as the eye would see it.

### Which pin is the ground on a traffic light module?

GND. It is the common cathode of the three LEDs, and it goes to the board’s ground.

How it is modeled

## What is true about the Traffic light module, here

In its help article’s own words: what the simulation gets right, and where it stops.

### Modeled

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.

### Not modeled

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).

From Traffic light module, in full.

Projects

## See the Traffic light module in a project

7 built-in projects use it. Each opens in the editor, already wired.

Lessons

## Where it turns up in a lesson

2 lessons place it in their own circuits.

### Learn articles

2 lessons

- Arduino Battery Level Indicator: 18650 on A0
- Arduino Fingerprint Sensor: Door Lock Code

Boards

## The boards it is shown on

This board has a built-in project with the Traffic light module in it.

- Arduino Uno R3

Keep going

## Keep going

- Picking a Resistor for an LED
- Arduino PWM Fade: analogWrite, Pins and the Curve
- LED
- Alcohol sensor, MQ-3

More parts

## The rest of the bench

Every one of these is drawn and simulated the same way.

Full-size breadboard

A real 0.1 inch grid with the rails and the center channel, 63 columns wide.

Jumper wires

Drag from any pin or hole to any other. Corners snap, and you can drag them.

Power

A supply rail at the voltage you choose.

Ground

The other end of every circuit.

LED

Lights when current flows. Five colors, and the brightness is what your eye would see.

Filament lamp

A tungsten bulb in a holder: an inrush when it is switched on cold, tens of milliseconds to warm up, and dim on half its voltage.

Resistor

Any value you like, with the color bands drawn to match.

ESP32-C3-DevKitM-1

A RISC-V board that runs your firmware at 160 MHz on the real memory map.

Pushbutton

A 12 mm tactile switch. Hold it while the simulation runs.

Raspberry Pi Pico

The RP2040 board on our own Cortex-M0+ core. Pick a program and press Run.

Raspberry Pi Pico W

Raspberry Pi Pico W (RP2040). The same board and the same pinout as a Pico, with the CYW43439 on it. The WiFi is simulated (no radio; real internet through the Cloud panel’s switch), and the on-board LED, which hangs off that chip rather than off GP25, is driven through the same path. Everything else is the Pico.

Raspberry Pi 4 Model B

Raspberry Pi 4 Model B: the 40-pin header, driven by main.py with RPi.GPIO or gpiozero.

See every part

## Wire up the Traffic light module

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.

Start building free Open the editor
