Blink an LEDTinkerPieCircuit tutorial 8 of 24 · Beginner · 10 minutes
Wire one LED and a resistor to the TinkerPie board and make it blink, the "hello world" of electronics.
Open this circuit in TinkerPieCircuit (free, runs in your browser)
What you will learn
- What a circuit is: a loop from a pin, through parts, back to GND
- Why an LED needs a resistor
- pinMode, digitalWrite and delay
Parts
Steps
Add the parts
Click Resistor and then LED in the Parts list. Keep the resistor at 220 Ω (select it to change the value).
Wire the signal
Drag from pin
S1on the board to one end of the resistor. Drag from the other end of the resistor to the leg marked + of the LED.Close the loop
Drag from the other leg (−) of the LED to the
GNDpin of the board. Electricity needs a full loop to flow.Write the code
Open the Code tab.
pinMode(S1, OUTPUT)makes S1 a power pin.digitalWrite(S1, HIGH)turns it on anddelay(500)waits half a second.Press Start
Press ▶ Start. The LED glows and fades every half second. Press ■ Stop to finish.
The code
function setup() {
pinMode(S1, OUTPUT);
}
function loop() {
digitalWrite(S1, HIGH);
delay(500);
digitalWrite(S1, LOW);
delay(500);
}
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
HIGH on a pin means 3.3 V. Current flows from S1, through the resistor and LED, and back to GND. The resistor limits the current so the LED is safe.
← RGB colour mixer · All 24 circuit tutorials · Button controls an LED →