Here is how to make an Arduino based robot at home: mount two geared DC motors on a chassis, connect them to an Arduino Uno through an L298N motor driver, add an HC-SR04 ultrasonic sensor, then upload code that drives forward and turns away from obstacles. Most kits need no soldering.
How to Make an Arduino Based Robot: What You Will Build
You will build a two-wheel-drive robot car that drives forward, measures the distance to whatever is ahead and turns away before it hits it. It is the classic first project because it teaches the three basics of all robots: sensing the world, deciding what to do, and moving motors in response.
The brain is an Arduino Uno R3, a board built around the ATmega328P microcontroller running at 16 MHz, with 14 digital input and output pins, six of which can produce PWM signals, and six analog inputs. That is plenty for two motors and a sensor, with pins to spare for later upgrades.
If you have wondered how to make a robot without an engineering degree, this is the gentlest path in. The same sense, decide and act loop runs inside far larger machines, from the mobile robots in our guide to robotics in warehouse material handling to industrial arms. Browse more builds and explainers in our Robotics & Automation section.
Should You Start with Arduino Robotic Kits or Loose Parts?
If you are learning how to make an Arduino-based robot for the first time, start with a kit. Arduino robotic kits bundle matching motors, wheels, a driver, a sensor and a chassis, so you spend your time learning rather than hunting for parts. Buy loose parts once you know what you want to change.
There are two broad kit styles. Generic two-wheel or four-wheel car kits use an Uno-compatible board and the same L298N and HC-SR04 parts described in this guide. Educational robots are more polished. Arduino Alvik, Arduino’s own robot for schools, runs on an Arduino Nano ESP32, can be programmed in MicroPython or the Arduino language, and includes a line-following sensor array, a time-of-flight distance sensor, a six-axis motion sensor and colour sensors.
In Australia, electronics retailers such as Core Electronics and Jaycar sell Arduino boards, robot chassis and kits. Compare what each kit includes, whether it needs soldering, and whether it comes with clear instructions and example code. Check current prices on the retailer’s own site, because they change often.
| Option | Best for | Trade-off |
|---|---|---|
| Generic car kit | Hobbyists and first-time builders who want to learn the wiring | Instructions vary in quality, and parts may need small adjustments |
| Educational robot such as Arduino Alvik | Schools, younger students and anyone who wants to focus on coding | Less hands-on wiring, higher cost than a basic kit |
| Loose parts | Builders who want a custom design or already own some parts | More time sourcing, checking compatibility and mounting |
Which Parts Do You Need?
You need an Arduino Uno or compatible board, an L298N motor driver module, two geared DC motors with wheels, a caster wheel, a chassis plate, an HC-SR04 ultrasonic sensor, jumper wires, a battery pack for the motors, a power source for the Arduino and a USB cable. A small screwdriver set and cable ties finish the toolkit.
| Part | What it does | Notes |
|---|---|---|
| Arduino Uno R3 or compatible | Runs your program and reads the sensor | Any Uno-compatible board works with this guide |
| L298N motor driver module | Lets the low-power Arduino control higher-current motors | Based on ST’s L298 dual full-bridge driver chip |
| Two geared DC motors with wheels | Drive the robot and steer it by changing speed | The yellow “TT” gear motors in most kits are fine |
| Caster or ball wheel | Supports the front or back so the robot balances | Usually included with the chassis |
| HC-SR04 ultrasonic sensor | Measures distance to objects ahead | Rated for roughly 2 cm to 4 m |
| Battery pack for motors | Powers the motors through the driver | Four to six AA cells or a suitable rechargeable pack |
| Power for the Arduino | Keeps the board running separately from the motors | A USB power bank or a 9 V battery to the barrel jack |
| Jumper wires and cable ties | Connect the parts and keep wires tidy | Male-to-female leads suit the sensor and driver pins |
The L298N module is built on ST’s L298 dual full-bridge driver, which accepts standard logic-level signals and can drive DC motors, relays and steppers. Each side of the chip controls one motor, letting you set its direction and speed independently.
Step 1: How to Construct a Simple Robot Chassis
To construct the chassis, screw the two motors to the underside of the plate, push the wheels onto the motor shafts, fit the caster at the other end, then mount the battery holder, the L298N module and the Arduino on top. Keep heavy parts low and central so the robot does not tip when it turns.
Many beginners ask how to construct a simple robot that actually drives straight. The answer is mostly mechanical: mount both motors square to the plate, make sure the wheels are pushed fully on, and check that neither wheel rubs on the chassis. Small differences between motors are normal, and you will balance them in code later.
- Fit the motors with their shafts pointing outwards and their wire tabs facing in.
- Attach the caster so the chassis sits level when all wheels touch the bench.
- Mount the HC-SR04 at the front, facing forward and clear of the wheels.
- Leave access to the Arduino’s USB port so you can upload code without dismantling anything.
- Use cable ties to keep wires away from the wheels.
Step 2: Wire the Motors, Driver and Power Safely
Connect each motor to one pair of L298N output terminals, the motor battery to the driver’s power input, and six Arduino pins to the driver’s control inputs. Then join the Arduino ground to the driver ground. Without that shared ground, the control signals have no common reference and the motors will behave erratically.
Keep motor power and Arduino power separate. The Arduino Project Hub version of this build warns in its code comments not to power motors from the Arduino, and not to power the Arduino from the motor driver. Motors draw surges of current that can reset or damage the board. A power bank on the USB port is the simplest way to run the Arduino.
| L298N pin | Connect to | Purpose |
|---|---|---|
| ENA | Arduino pin 5 (PWM) | Left motor speed |
| IN1 | Arduino pin 7 | Left motor direction |
| IN2 | Arduino pin 8 | Left motor direction |
| ENB | Arduino pin 6 (PWM) | Right motor speed |
| IN3 | Arduino pin 9 | Right motor direction |
| IN4 | Arduino pin 10 | Right motor direction |
| OUT1 and OUT2 | Left motor wires | Drive the left wheel |
| OUT3 and OUT4 | Right motor wires | Drive the right wheel |
| Power input (often labelled 12V) | Motor battery positive | Motor supply |
| GND | Motor battery negative and Arduino GND | Shared ground |
Remove the small jumpers on ENA and ENB if your module has them, so the Arduino controls speed through PWM. On the Uno, pins 3, 5, 6, 9, 10 and 11 support PWM, which is why the enable pins use 5 and 6. The L298 also loses some voltage inside the chip, so your motors will run a little slower than the battery voltage suggests.
Step 3: Add the Ultrasonic Sensor So the Robot Can See
Wire the HC-SR04’s VCC pin to the Arduino’s 5V pin, GND to GND, TRIG to pin 12 and ECHO to pin 11. The sensor works like a bat: it sends a short burst of ultrasound and times how long the echo takes to return. Your code turns that time into a distance in centimetres.
When the TRIG pin receives a pulse of at least 10 microseconds, the module sends eight ultrasonic cycles at 40 kHz and raises the ECHO pin for as long as the sound takes to travel out and back. Sound travels at about 343 metres per second in room-temperature air, or 0.0343 centimetres per microsecond. Multiply the echo time by 0.0343 and divide by two, because the sound made a return trip.
The sensor works best on flat, hard surfaces facing it. Soft fabric, thin chair legs and objects at sharp angles can reflect too little sound, so expect the occasional missed obstacle. Readings under about 2 cm are unreliable, which is one reason to set your turning distance well above that.
Step 4: How to Code a Robot with the Arduino IDE
To code the robot, install the free Arduino IDE, select the Arduino Uno board and its USB port, then write a sketch with two parts: setup, which runs once to configure the pins, and loop, which runs forever. In the loop, read the distance, decide whether the path is clear, and set the motors.
The Arduino software page offers the desktop Arduino IDE 2 and a free browser-based Cloud Editor, so you can work on Windows, macOS, Linux or a Chromebook. Learning how to code a robot is mostly about breaking behaviour into small, named functions you can test one at a time.
- Define names for each pin at the top of the sketch, such as the enable, input, trigger and echo pins, so the code reads clearly.
- In setup, set the six motor pins and the TRIG pin as outputs, the ECHO pin as an input, and start the serial monitor at 9600 baud for debugging.
- Write a distance function that sets TRIG low briefly, high for 10 microseconds, then low, measures the ECHO pulse with the pulseIn function and returns the time multiplied by 0.0343 and divided by two.
- Write motor functions for forward, backward, turn left, turn right and stop. Each one sets the IN pins high or low for direction and uses analogWrite on the enable pins for speed, from 0 to 255.
- In loop, read the distance. If it is more than about 25 cm, drive forward. If not, stop, reverse briefly, turn for a fraction of a second, then check again.
- Add a short delay of around 50 milliseconds at the end of each loop so the sensor’s echoes do not overlap.
Print each distance reading to the serial monitor while you test. Seeing the numbers change as you move your hand in front of the sensor is the fastest way to confirm that wiring and code agree before the wheels ever touch the floor.
Step 5: Test, Calibrate and Fix Common Problems
Test in stages: first the sensor alone using the serial monitor, then the motors with the robot propped up so the wheels spin freely, then short runs on the floor. Fix one problem at a time. Most first-build faults come from a loose jumper wire, a missing shared ground, a flat battery or a motor wired backwards.
Calibrate on a smooth floor. If the robot drifts, lower the speed value for the faster motor until it tracks straight. If it turns too far or not far enough, change the turn time. If it stops too late, raise the obstacle distance. Write down each change so you can undo it.
| Symptom | Likely cause | Fix |
|---|---|---|
| One wheel spins the wrong way | Motor wires reversed | Swap that motor’s two wires at the L298N terminals |
| Motors hum but do not turn | Speed value too low or weak batteries | Raise the PWM value or fit fresh batteries |
| Arduino resets when motors start | Board and motors sharing a supply | Power the Arduino separately and join the grounds |
| Distance always reads zero | TRIG and ECHO swapped or not connected | Check the sensor wiring against your pin names |
| Robot hits soft obstacles | Fabric absorbs the ultrasound | Raise the turning distance or add a second sensor type |
| Upload fails | Wrong board or port selected | Choose Arduino Uno and the correct port in the IDE |
Where Can You Take Your Robot Next?
Once the basic robot works, add one upgrade at a time: a servo that sweeps the sensor left and right, infrared sensors for line following, wheel encoders for accurate distance, or a Bluetooth module for phone control. Each upgrade teaches a new idea in sensing or control without starting from scratch.
These ideas scale up. Line following is the ancestor of the guided vehicles in factories, wheel encoders underpin precise movement, and remote control leads to teleoperation. In medicine, surgeon-controlled systems use far more advanced versions of these ideas, as our explainer on what robotic surgery is explains.
- Servo scanning: mount the HC-SR04 on a small servo and pick the clearest direction before turning.
- Line following: add infrared reflectance sensors and steer to keep a dark line centred.
- Encoders: count wheel rotations so the robot can drive set distances and turn set angles.
- Wireless control: add a Bluetooth module and drive the robot from a phone app.
- New brains: move to a board with Wi-Fi, such as an ESP32-based Arduino, for app or cloud control.
How Do You Build Safely at Home?
Build safely by disconnecting batteries before changing wires, never shorting battery terminals, using the right charger for rechargeable packs, and supervising children around tools, small parts and batteries. Lithium batteries can overheat or catch fire if damaged or charged incorrectly, so store and charge them away from flammable materials.
- Disconnect the motor battery whenever you change the wiring.
- Check polarity before connecting any battery to the driver or the Arduino.
- Keep coin and button batteries well away from young children.
- Work in a ventilated space if you solder, and use a stand for the hot iron.
Build Your First Robot This Weekend
Now you know how to make an Arduino based robot: assemble a simple chassis, wire the motors through an L298N with separate power and a shared ground, add an HC-SR04 sensor, write a sense, decide and act loop, then test and tune it step by step. It is a small project that teaches the foundations of every robot.
Pick a kit or gather the parts, set aside an afternoon and build it. When it works, choose one upgrade from the list above. For more projects and the bigger picture on automation, explore Robotics & Automation, read how robots move goods in warehouse material handling, and subscribe to the Briefing for new guides every weekday.
Sources
- UNO R3 Arduino Documentation
- Arduino Alvik Arduino Education
- Software: Arduino IDE and Cloud Editor Arduino
- L298 dual full-bridge driver STMicroelectronics
- Obstacle detecting Robot Arduino Project Hub





