Robotics · Step 2 of 8 · 6 min
Electronics basics and microcontrollers
You can wire an LED safely and make a microcontroller blink it.
Voltage, current, resistance
Voltage is the push, measured in volts. Current is the flow, in amps. Resistance slows the flow, in ohms. Ohm's law links them: voltage equals current times resistance.
That one rule explains why an LED needs a resistor in series. Without it, too much current flows and the LED or the pin burns out. Around 220 to 330 ohms is a common starting value on 5 V.
Microcontrollers
A microcontroller is a tiny computer on one chip. It runs one program, starts in a blink and talks directly to pins. That makes it ideal for reading sensors and driving motors.
Arduino Uno boards use 5 V logic and are the classic way to start. ESP32 boards are cheap, faster and add Wi-Fi and Bluetooth, but use 3.3 V logic. Feeding 5 V into an ESP32 pin can damage it.
Pins and code
Digital pins are on or off. Analog inputs read a range, like a knob or a light sensor. PWM pins switch on and off very fast, which lets you dim an LED or set a motor's speed.
An Arduino program has two parts. setup() runs once. loop() runs forever. You will write almost all robot code inside that forever loop.
Power and safety
Never power a motor straight from a microcontroller pin. Pins give only a few tens of milliamps. Motors get their own supply and a driver, with the grounds connected.
Lithium batteries, especially LiPo packs, store a lot of energy. Use a proper charger, never charge them unattended, and retire any pack that is puffed or damaged. Disconnect power before you change wiring.
Try it
Blink an LED in a free simulator
- 1.Open wokwi.com and start a new Arduino Uno project. No account or hardware needed to try.
- 2.Add an LED and a 220 ohm resistor, and wire them from pin 13 to ground.
- 3.Write a sketch that turns pin 13 on for 500 ms and off for 500 ms, then press play.
- 4.Change the timing and watch the LED change. Then remove the resistor and read why a real LED would be at risk.