Step-by-step projects that go beyond the screen — real circuits, real code, real physics. Build it, then snap it in SnapCurio to unlock science facts, math challenges, and Why Videos about what you just made.
Build a self-driving car that detects obstacles and steers around them — the same fundamental principle behind real autonomous vehicles, at 1/100th the scale.
How an electric car works
Energy from the battery powers the motor, which turns the wheels.
The Arduino is the brain. It reads the ultrasonic sensor, decides what the car should do, and tells the motor driver how to spin the wheels.
Gather everything before you start. Most 4WD Arduino kits include the chassis, motors, wheels, and driver in one box.
Follow each step in order. Take your time with the wiring — getting connections right is the most important part.
Attach the four DC gear motors to the motor mounts on the chassis frame. Secure the caster wheel at the front. Mount the wheels on each motor shaft. All screws should be tight before any electronics go on top.
💡 Test that each wheel spins freely before moving onMount the Arduino Uno on top using standoffs or double-sided tape. Place the L298N motor driver next to it. Secure the 18650 battery holder underneath for low centre of gravity. Mount the ultrasonic sensor at the front, facing forward.
💡 Keep batteries low and central — it improves balanceWire the left motors together and the right motors together into the L298N outputs. Connect the L298N input pins to Arduino digital pins. Wire HC-SR04 Trig → Arduino pin 9, Echo → pin 10. Connect battery power to both the L298N (motor rail) and Arduino (Vin). Connect all GNDs together — this is critical.
⚠️ Always double-check polarity before connecting powerConnect the Arduino to your laptop via USB. Open the Arduino IDE (arduino.cc), paste in the code below, select Board: Arduino Uno and the correct COM port. Click Upload. "Done uploading" means it worked.
💡 The Arduino IDE is free to download from arduino.ccDisconnect the USB cable. Make sure the battery switch is OFF. Insert the batteries, then flip ON. The Arduino power LED should glow green. Your car is now running entirely on its own power.
💡 Place the car on a flat surface before switching onPut the car on the floor with clear space ahead. It should roll forward automatically. Hold your hand in front of the ultrasonic sensor — it should stop, reverse, and turn to avoid you. Experiment with different obstacle distances and surfaces.
🎉 Car moves and avoids obstacles? You built it!This runs on your Arduino. Every loop it reads the distance sensor and decides whether to go forward, stop and reverse, or turn — real embedded programming logic.
// ── Pin Definitions ────────────────────────────── const int TRIG_PIN = 9; const int ECHO_PIN = 10; // L298N Motor Driver pins const int ENA = 5; // Left motor speed (PWM) const int IN1 = 2; // Left motor direction A const int IN2 = 3; // Left motor direction B const int ENB = 6; // Right motor speed (PWM) const int IN3 = 4; // Right motor direction A const int IN4 = 7; // Right motor direction B const int STOP_DIST = 20; // cm — stop if obstacle within 20 cm // ── Setup ──────────────────────────────────────── void setup() { pinMode(TRIG_PIN, OUTPUT); pinMode(ECHO_PIN, INPUT); pinMode(ENA, OUTPUT); pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT); pinMode(ENB, OUTPUT); pinMode(IN3, OUTPUT); pinMode(IN4, OUTPUT); Serial.begin(9600); } // ── Read Distance from HC-SR04 ─────────────────── long readDistance() { digitalWrite(TRIG_PIN, LOW); delayMicroseconds(2); digitalWrite(TRIG_PIN, HIGH); delayMicroseconds(10); digitalWrite(TRIG_PIN, LOW); long dur = pulseIn(ECHO_PIN, HIGH); return dur * 0.034 / 2; // convert to cm } // ── Motor Helpers ──────────────────────────────── void moveForward() { digitalWrite(IN1,HIGH); digitalWrite(IN2,LOW); digitalWrite(IN3,HIGH); digitalWrite(IN4,LOW); analogWrite(ENA,180); analogWrite(ENB,180); } void moveBackward() { digitalWrite(IN1,LOW); digitalWrite(IN2,HIGH); digitalWrite(IN3,LOW); digitalWrite(IN4,HIGH); analogWrite(ENA,180); analogWrite(ENB,180); } void turnLeft() { digitalWrite(IN1,LOW); digitalWrite(IN2,HIGH); digitalWrite(IN3,HIGH); digitalWrite(IN4,LOW); analogWrite(ENA,180); analogWrite(ENB,180); } void stopMotors() { analogWrite(ENA,0); analogWrite(ENB,0); } // ── Main Loop ──────────────────────────────────── void loop() { long distance = readDistance(); Serial.println(distance); if (distance < STOP_DIST) { // obstacle! stopMotors(); delay(500); moveBackward(); delay(1000); turnLeft(); // try turnRight() too delay(600); } else { moveForward(); } }
Every component teaches a real science concept. Here's what you're actually learning while you solder and code.
Li-ion cells store chemical energy and convert it to electrical. Voltage × current = power. More capacity = more range — just like a Tesla.
Current through wire coils inside a magnetic field creates a rotational force (torque). This converts electrical energy into mechanical motion.
Emits 40 kHz sound pulses invisible to humans. Times the echo to calculate distance: d = speed × time ÷ 2. Same principle as bat echolocation.
The Arduino runs your code 50+ times per second — reads sensor data, makes decisions, outputs signals. This is embedded programming.
HC-SR04 bounces ultrasonic pulses off objects and times the echo — measuring distance without touching anything.
Within 20 cm of an obstacle, the car stops, reverses, then turns — no remote required.
Two motors spin at different speeds or directions to turn. Same principle as a tank or skid-steer loader.
Battery → driver → motors. The same fundamental chain as a full-scale electric vehicle, scaled to fit on a desk.
Runs on 18650 Li-ion batteries with no USB needed. Learn about energy capacity, runtime, and discharge curves.
Change a number in the code and watch the car behave differently. That direct feedback loop is the core of engineering.
Once your car is working, these upgrades will push your skills further. Each one is a separate mini-project.
Add a 0.96" OLED screen to display live speed, battery percentage, or real-time obstacle distance.
Add an HC-05 Bluetooth module. Build a phone app to manually override the autonomous mode.
Mount IR sensors underneath. Program the car to follow a black tape line — the basis of warehouse logistics robots.
Wire a small solar panel to a charging circuit. Study how renewable energy keeps the battery topped up passively.
Point the SnapCurio camera at your finished car and get an AI-generated science lesson about electric motors, a math challenge on speed and distance, and a Why Video on how EVs actually work.