Why the green is different
The green LED takes nearly a volt more than the red and yellow before it conducts, so the same 1 kΩ resistor leaves it less current: about 2.3 mA from a 5 V pin against about 3.1 mA for the other two. Its datasheet rates it bright at small currents, which is why it does not look it.
Where the volts go
Each bar is the pin's voltage, split between an LED and its resistor. The coloured part is the LED's share, and it barely moves as you slide the pin voltage. The orange part is the resistor's share, which is everything left over, and only that sets the current.
With 1 kΩ, a volt across the resistor is a milliamp through it. So the length of the orange part, in volts, is the current in milliamps.
The green keeps more for itself
Every LED takes a roughly fixed voltage before it conducts, and the colour decides it. The three datasheets give these ranges:
| Light | Part | Forward voltage | Tested at |
|---|---|---|---|
| Red | NATIONSTAR NCD0805R1 | 1.5 to 2.6 V | not stated |
| Yellow | KENTO KT-0805Y | 1.8 to 2.4 V | 10 mA |
| Green | KENTO KT-0805G | 2.6 to 3.1 V | 5 mA |
At the few milliamps a 1 kΩ resistor allows, the red and yellow take about 1.9 V and the green about 2.7 V. From a pin, that works out as:
| Your board | Red | Yellow | Green |
|---|---|---|---|
| Uno, 5 V | about 3.1 mA | about 3.1 mA | about 2.3 mA |
| ESP32, ESP32-S3, Pico, 3.3 V | about 1.4 mA | about 1.4 mA | about 0.6 mA |
These are worked out, not measured, and a real LED can sit anywhere in its range. The shape is what holds: the green always gets the least, and on a 3.3 V board it gets less than half of what the others do.
It still looks as bright
Less current does not mean less light here, because the parts are not equally efficient. The yellow's datasheet gives its brightness at 20 mA: 70 to 175 millicandela. The green's gives its brightness at 5 mA, a quarter of that current, and the range is 175 to 430 millicandela. The green's dimmest part is as bright as the yellow's brightest, on a quarter of the current. The eye also happens to be most sensitive to light near yellow-green.
So on an Uno the three look much alike. On a 3.3 V board the green is visibly the dimmest of the three, but plainly lit. Why it is dimmer on 3.3 V works the same arithmetic for the XL LED's blue.
Safe on every board
The largest current here is about 3.1 mA per pin, and about 8.5 mA for all three together from an Uno. An Uno's pin may supply 40 mA, an ESP32's about 20 mA at its default drive, and a Pico's 4 mA at its default. Every board in this book is well inside its limit with all three lights on.
When it does not work
From a 3.3 V pin the green gets well under a milliamp, against about 1.4 mA for the red and yellow, because it keeps about 2.7 V for itself. Some dimness is expected. If it matters, run the block from a 5 V board, where the green gets about 2.3 mA.
Yes. analogWrite on the red and yellow pins at less than full duty dims them towards the green. The pins in this book can all do PWM. It is a matter of taste: every LED's brightness varies from part to part, and the datasheets allow a wide range.
It is soldered to the board, and 1 kΩ is a safe value for every pin you are likely to use. A smaller one would help most on a 3.3 V board and least where it is already bright. The honest fix for a brighter light is a 5 V board.
No. They are worked out from the forward voltages in the three datasheets, which each give a range rather than one number. A real board will be within a few tenths of a milliamp of them, so every figure here says about.
Red, green, yellow, and a sketch that spends almost all of its time waiting.
The first sequence →Edit this page — content/books/traffic-light/why-the-green-is-different.mdx
Questions about this product
See what other owners have asked, and read their solutions.
Traffic Light
Loading discussions…
Discuss this article
Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.