Why LEDs need a resistorTinkerPieCircuit tutorial 14 of 24 · Beginner · 10 minutes
See what happens when an LED is connected without a resistor, and fix it. Learn about current and safe circuits.
Open this circuit in TinkerPieCircuit (free, runs in your browser)
What you will learn
- What current is, and why too much is harmful
- Reading the warnings in the simulator
- Choosing a safe resistor value
Parts
Steps
Build the unsafe circuit
Wire
S1straight to the LED (+) and the LED (−) toGND. No resistor!Predict
Ask: what will happen? An LED has almost no resistance when it is on, so a lot of current will flow.
Press Start
The program turns S1 on. The LED shows a ✕ and the warning says it burnt out. In real life it would be ruined.
Fix it
Press ■ Stop. Remove the wire from S1 to the LED. Add a 220 Ω resistor between S1 and the LED (+).
Run again
Press ▶ Start. The LED now glows safely. Hover a pin while running to see its voltage.
The code
function setup() {
pinMode(S1, OUTPUT);
digitalWrite(S1, HIGH);
}
function loop() {
}
Copy this into the Code tab. It is Arduino-style JavaScript. The real board uses the same pin names (S1, P10…) in TinkerPie Studio.
How it works
Current = (3.3 V − LED voltage) ÷ resistance. With 220 Ω that is about 6 mA for a red LED, which is safe and bright. With nothing in the way, the current is around 40 mA or more.
← Play a melody with a buzzer · All 24 circuit tutorials · Traffic light →