By Kevin McAleer, 6 Minutes
Page last updated November 24, 2026

By the end of this lesson you will be able to find the key numbers on a datasheet and read a four band resistor colour code.
Every component has a datasheet: a short document from the maker that says what the part can and cannot do. They look intimidating, but you only need a handful of numbers from each. In this lesson we learn where to find them for the parts in our night light, and how to read resistor colour bands, which are a tiny datasheet printed on the part.
Using a datasheet number to choose a resistor looks like this:
flowchart LR
A["Find the LED's Vf<br>and wanted current"] --> B["Supply minus Vf<br>= voltage left for the resistor"]
B --> C["R = that voltage / current"]
C --> D["Round up to the<br>next E12 value"]
Datasheets usually have a table of absolute maximum ratings (do not exceed these or the part may be damaged) and a table of typical characteristics (what you can expect in normal use). A good rule: design around the typical values, and stay well under the maximums.
Search for the LED’s datasheet, or the shop listing, and look for:
Note that a blue or white LED with Vf of 3.0 V or more will barely light, or not at all, from a 3.3 V Pico pin once you add a resistor. For the Pico, red, yellow and green LEDs are the easy choice.
Let’s use datasheet numbers in code:
# Run on your computer or the Pico
# Resistor for an LED, straight from datasheet numbers
led_datasheet = {
"red": {"vf": 2.0, "max_ma": 20},
"green": {"vf": 2.1, "max_ma": 20},
"blue": {"vf": 3.1, "max_ma": 20},
}
supply = 3.3
wanted_ma = 10
for colour, data in led_datasheet.items():
headroom = supply - data["vf"]
if headroom < 0.5:
print(f"{colour:<6}: only {headroom:.1f} V left for the resistor, too tight")
else:
ohms = headroom / (wanted_ma / 1000)
print(f"{colour:<6}: {ohms:.0f} ohm for {wanted_ma} mA")
Output:
red : 130 ohm for 10 mA
green : 120 ohm for 10 mA
blue : only 0.2 V left for the resistor, too tight
Resistors are too small for printed numbers, so they use coloured bands. For the usual 4-band resistor, read from the end away from the gold or silver band:
The colours as digits:
black 0, brown 1, red 2, orange 3, yellow 4, green 5, blue 6, violet 7, grey 8, white 9
Examples:
A tiny decoder, so you can check your reading:
# Run on your computer or the Pico
# Decode a 4-band resistor colour code
DIGITS = ["black", "brown", "red", "orange", "yellow",
"green", "blue", "violet", "grey", "white"]
def decode(band1, band2, multiplier):
value = (DIGITS.index(band1) * 10 + DIGITS.index(band2)) * 10 ** DIGITS.index(multiplier)
return value
for bands in [("red", "red", "brown"),
("orange", "orange", "brown"),
("brown", "black", "orange"),
("yellow", "violet", "red")]:
print(" ".join(bands), "=", decode(*bands), "ohm")
Output:
red red brown = 220 ohm
orange orange brown = 330 ohm
brown black orange = 10000 ohm
yellow violet red = 4700 ohm
If you can’t tell which end to start from, use your multimeter. It never lies, and that is what lesson 6 was for.
For the night light’s transistor, look for:
Why this matters: a datasheet lookup takes two minutes and avoids burnt parts and mystery faults. It is a great habit for every part in your robot.
Why: Starting high is the safe direction.
Quick quiz 1 of 3
Which resistor colour code reads 4.7k?
Quick quiz 2 of 3
Why do blue and white LEDs struggle on a 3.3 V Pico pin?
Quick quiz 3 of 3
How should you design with a datasheet’s two tables?
Comments