Example-1
Blink an LED in Tinkercad Circuits
Objective
Use Arduino Uno to blink an LED on and off with a fixed delay. Students learn pin mapping, current-limiting resistors, and the basic Arduino program structure.
Learning outcomes
-
Identify Arduino digital pins and GND
-
Build a simple LED circuit on a breadboard
-
Write, upload, and run an Arduino sketch in Tinkercad
-
Explain
setup()
vsloop()
andpinMode()
vsdigitalWrite()
Prerequisites
-
Tinkercad account and access to Circuits
-
Know how to create a New Circuit project
-
Basic idea of breadboard rows and power rails
Components (Tinkercad palette)
-
Arduino Uno R3
-
Breadboard (small)
-
1× LED (any color)
-
1× Resistor 220 Ω (or 330 Ω)
-
2× Wires (male-male)
Why the resistor? To limit current through the LED and protect the Arduino pin.
Circuit wiring
You can do this straight on the Uno (using the built-in LED on pin 13) or, better for learning, on a breadboard.
Option A — Recommended (external LED on Pin 8):
-
Place the LED on the breadboard. Long leg = anode (+), short leg = cathode (–).
-
Connect Arduino pin 8 → LED anode row (same row as long leg).
-
Put the 220 Ω resistor from the LED cathode row → GND rail on the breadboard.
-
Wire Arduino GND → breadboard GND rail.
Option B — Quick test (use onboard LED):
-
No breadboard. Just code for pin 13 (onboard LED). Good as a fallback.
Step-by-step in Tinkercad
-
Create the project: Tinkercad → Circuits → Create new Circuit.
-
Place parts: Drag Arduino Uno and Breadboard into the workspace.
-
Wire: Follow Option A wiring above. Use the color chooser to keep GND wires black for clarity.
-
Start coding: Click Code → choose Text (C/C++).
-
Paste this sketch (for Pin 8):
// EXP-1: Blink LED on Digital Pin 8
const int LED_PIN = 8;
void setup() {
pinMode(LED_PIN, OUTPUT); // Set pin as output
}
void loop() {
digitalWrite(LED_PIN, HIGH); // LED ON
delay(1000); // wait 1 second (1000 ms)
digitalWrite(LED_PIN, LOW); // LED OFF
delay(1000); // wait 1 second
}
(If using onboard LED: set LED_PIN = 13
and you can skip the breadboard.)
-
Simulate: Click Start Simulation. The LED should blink ON/OFF every second.
-
Tweak: Change
delay(1000)
todelay(200)
to blink faster; re-run the simulation.
How it works
-
setup()
runs once when the Arduino starts. -
loop()
runs forever. -
pinMode(8, OUTPUT)
tells Arduino to drive pin 8. -
digitalWrite(…, HIGH/LOW)
sets the voltage to 5V/0V → LED ON/OFF. -
delay(ms)
pauses the program.
Common mistakes & quick fixes
-
LED not lighting: Flip the LED; long leg (anode) must go to the pin, short leg to GND (through resistor).
-
No resistor used: Always add 220–330 Ω in series or you can damage real hardware.
-
Wrong pin number: Code says 8 but you wired to 7 or 9—match them.
-
Floating ground: Ensure Arduino GND is connected to the breadboard GND rail.
Viva / check-your-understanding
-
Why do we need a resistor with an LED?
-
What’s the difference between
setup()
andloop()
? -
What happens if we change the delay to
50
ms?
Extensions (mini-tasks)
-
Custom pattern: Blink ON 200 ms, OFF 800 ms to simulate a “heartbeat” LED.
-
Two LEDs: Add a second LED on pin 9 and alternate them.
-
Fade (bonus): Replace blink with PWM on pin 9 using
analogWrite(9, value)
.
Lab record (suggested headings)
-
Aim
-
Circuit diagram (screenshot from Tinkercad)
-
Code listing
-
Output observation (simulation screenshot)
-
Inference/Conclusion
Comments
Post a Comment