Getting Started with Arduino for Robotics
Every robot on this site is driven by an Arduino-compatible board, so this is the guide to start with if you have never uploaded a sketch before. In about 45 minutes you will blink an LED, build a real circuit on a breadboard, read an analog sensor, and control brightness with PWM — the exact skills the robot car build assumes.
What is an Arduino?
An Arduino Uno is a small circuit board built around an ATmega328P microcontroller. Unlike a PC, it runs exactly one program (a sketch) the moment power arrives, forever, until you replace that program. Its 20 input/output pins can read buttons and sensors and switch LEDs, buzzers, and — through a driver board — motors. That combination of “read inputs, decide, drive outputs” is all a hobby robot is.
For learning, an Uno-compatible (“clone”) board is perfectly fine and costs a fraction of the original. Boards with the CH340 USB chip may need a one-time driver install on Windows.
What you need
| Part | Notes | Indicative price (India) |
|---|---|---|
| Arduino Uno R3 (compatible board is fine) | USB-B cable usually included — check | ₹400–800 |
| Half-size breadboard (400 points) | For solder-free circuits | ₹60–100 |
| Jumper wires, male–male ×20+ | Dupont type | ₹60–120 |
| 5 mm LEDs ×5 + 220 Ω resistors ×5 | Any colour | ₹30–60 |
| 10 kΩ potentiometer | Our first “sensor” | ₹20–40 |
Prices shown are indicative online street prices in India as of mid-2026. They vary by seller and stock — treat them as a budgeting guide, not a quote.
Install the IDE and upload Blink
- Download the free Arduino IDE from arduino.cc/en/software (Windows, macOS, Linux).
- Connect the Uno with its USB cable. A power LED should light immediately.
- In the IDE choose Tools → Board → Arduino Uno and Tools → Port (the COM port that appeared when you plugged in).
- Paste the sketch below and press the Upload (arrow) button.
// Blink — your first Arduino sketch
void setup() {
pinMode(LED_BUILTIN, OUTPUT); // pin 13 on an Uno
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // LED on
delay(500); // wait 500 ms
digitalWrite(LED_BUILTIN, LOW); // LED off
delay(500);
}The on-board LED next to pin 13 should now blink once per second. If upload fails, 95% of the time it is the wrong port selected or a charge-only USB cable.
Understanding the sketch
Every sketch has the same skeleton. setup() runs once at power-on — use it to declare which pins are inputs or outputs. loop() then repeats forever, thousands of times per second unless you slow it down. digitalWrite(pin, HIGH) puts 5 V on a pin; LOW puts 0 V. delay(ms) pauses everything — fine for now, though later robot code avoids long delays so it can keep checking sensors.
Your first breadboard circuit
Now move the LED off the board so you learn real wiring. On a breadboard, the five holes in each short row are connected internally, and the long rails down the sides run the full length (use them for 5 V and GND).
- Wire Arduino GND to the blue rail, 5 V to the red rail.
- Place the LED across two rows. The longer leg is positive (anode).
- Connect a 220 Ω resistor from the anode row to Arduino pin 9.
- Connect the short leg (cathode) row to the GND rail.
Change LED_BUILTIN to 9 in the Blink sketch, upload, and your external LED blinks.
An LED will happily draw enough current to destroy itself (and stress the Arduino pin, which is rated for 40 mA absolute max). The 220 Ω resistor limits current to a safe ~14 mA. Never connect an LED directly.
Read a sensor with analogRead
Robots are only interesting because they sense the world. The simplest analog sensor is a potentiometer: wire its outer legs to 5 V and GND and the middle leg (wiper) to A0. The voltage on the wiper varies smoothly from 0 to 5 V as you turn the knob, and analogRead converts it to a number from 0 to 1023.
// Read a potentiometer and print the value
const int POT = A0;
void setup() {
Serial.begin(9600);
}
void loop() {
int raw = analogRead(POT); // 0..1023
float volts = raw * (5.0 / 1023.0); // convert to volts
Serial.print(raw);
Serial.print(" -> ");
Serial.print(volts);
Serial.println(" V");
delay(200);
}Open Tools → Serial Monitor at 9600 baud and turn the knob. This read-convert-print pattern is exactly how you will debug IR line sensors and ultrasonic rangefinders later.
PWM: the trick behind motor speed control
Arduino pins are digital — on or off — so how do you get half brightness or half speed? Pulse-width modulation: switch the pin on and off hundreds of times per second and vary the ratio of on-time. analogWrite(pin, 0–255) does this on the PWM pins (3, 5, 6, 9, 10, 11 on an Uno, marked with ~).
// Fade an LED with PWM (pin must support PWM: 3, 5, 6, 9, 10, 11 on Uno)
const int LED = 9;
void loop() {
for (int b = 0; b <= 255; b += 5) { analogWrite(LED, b); delay(20); }
for (int b = 255; b >= 0; b -= 5) { analogWrite(LED, b); delay(20); }
}
void setup() {
pinMode(LED, OUTPUT);
}When you build the robot car, the exact same analogWrite call sets motor speed through the motor driver’s EN pins.
Common beginner mistakes
- Wrong COM port / cable. Charge-only USB cables have no data lines. If no new port appears, swap the cable first.
- Powering big loads from the 5 V pin. Motors and servos need their own supply; the Uno regulator can only source a few hundred mA.
- Missing common ground between the Arduino and anything it talks to.
- Semicolons and case.
digitalwriteis notdigitalWrite; the compiler error messages point at or just after the mistake. - Pin 0 and 1. Leave them free — they are the USB serial pins, and wiring on them breaks uploads.