Build OctoBot — the 8‑legged robot that vacuums and climbs stairs!
Most robot vacuums roll around on wheels and get stuck at the bottom of every staircase. OctoBot doesn't — it walks on eight bendy legs, so it can climb right up and keep cleaning. Here's exactly how to build one, with the full circuit and code, in steps easy enough for a young maker with a grown-up helper.
Why 8 legs beat wheels
A wheeled robot vacuum can only roll on flat floors. The moment it meets a step, it either falls, gets stuck, or just gives up. Legs solve this because each one can lift, reach, and grip a new surface on its own.
Legs lift over edges
Each leg can rise higher than a wheel ever could, so OctoBot steps up onto a stair instead of bumping into it.
8 legs = always stable
With eight legs, at least four stay planted on the ground at all times, like a table that never wobbles.
A spinning brush + suction fan
While it walks, a small motor spins a brush and fan underneath to sweep dust into a little collection bin.
What you'll need
Everything here is beginner-friendly and available from hobby electronics stores. Ask a grown-up to help you order the parts.
Arduino Uno or Nano
The microcontroller that runs your code and controls every motor.
8× SG90 micro servo motors
One servo per leg, so each leg can swing up, forward, and down.
2× 18650 batteries + holder
Gives about 7.4V — enough for the servos and vacuum motor together.
L298N motor driver board
Lets the Arduino safely control the stronger vacuum motor.
Small 6V DC motor + mini fan/brush
Creates suction and sweeps dust into a small bin underneath.
HC-SR04 ultrasonic sensor
"Looks" ahead so OctoBot can find stair edges and avoid falling backward.
Breadboard + jumper wires
Connects everything together without soldering.
Cardboard or 3D-printed chassis
A light, oval body to mount the servos, motor, and electronics.
How the circuit works
Think of it as three teams reporting to one manager: the Arduino (manager) tells the 8 leg servos when to move, tells the motor driver when to spin the vacuum motor, and listens to the ultrasonic sensor for stair edges.
[ 2x 18650 Battery Pack, 7.4V ]
| |
| +------------------> L298N (+12V in) --> Vacuum Motor
|
+--> 5V Regulator --> Arduino 5V pin
|
Arduino Uno / Nano ------------+
D2 -> Leg Servo 1 (front-left)
D3 -> Leg Servo 2 (front-right)
D4 -> Leg Servo 3 (mid-left-1)
D5 -> Leg Servo 4 (mid-right-1)
D6 -> Leg Servo 5 (mid-left-2)
D7 -> Leg Servo 6 (mid-right-2)
D8 -> Leg Servo 7 (back-left)
D9 -> Leg Servo 8 (back-right)
D10 -> L298N IN1 (vacuum motor ON/OFF)
D11 -> Ultrasonic TRIG
D12 -> Ultrasonic ECHO
GND -> shared with battery GND + L298N GND
Step-by-step build
Work through these steps in order. Each one builds on the last, so don't skip ahead.
Cut and shape the body
Cut an oval chassis from stiff cardboard (or 3D print one). Mark 8 evenly spaced mounting points around the edge — 4 per side — for the leg servos.
Mount the 8 leg servos
Glue or screw each SG90 servo into its mounting point, horn facing outward. Attach a simple L-shaped leg arm to each servo horn.
Add the vacuum unit underneath
Mount the small DC motor with its fan/brush attachment in the center-bottom of the chassis, right above a small dustbin tray.
Wire the servos to the Arduino
Connect each servo's signal wire to pins D2–D9 as shown in the circuit map. Connect all servo power/ground lines to the shared battery rail.
Wire the motor driver and vacuum motor
Connect the L298N to the battery, the vacuum motor, and Arduino pin D10, following the circuit diagram above.
Add the ultrasonic "eyes"
Mount the HC-SR04 facing forward and slightly downward at the front of the chassis, then wire TRIG and ECHO to D11 and D12.
Upload the code
Plug the Arduino into a computer, open the Arduino IDE, paste in the OctoBot sketch below, and click Upload.
Test on flat ground first
Place OctoBot on a flat floor before trying stairs. Watch its walking gait, and only move to a real staircase once it walks smoothly.
The Arduino code
This sketch moves OctoBot's 8 legs in an alternating "tripod-style" gait (like a real ant or spider), runs the vacuum motor while walking, and uses the ultrasonic sensor to detect a stair edge so it lifts its front legs higher to climb.
// OctoBot — 8-legged stair-climbing vacuum robot // Beginner-friendly Arduino sketch #include <Servo.h> Servo legs[8]; const int legPins[8] = {2,3,4,5,6,7,8,9}; const int vacuumPin = 10; const int trigPin = 11; const int echoPin = 12; const int STAND = 90; // neutral leg angle const int LIFT = 50; // lifted leg angle const int STEP = 120; // forward reach angle void setup() { for (int i = 0; i < 8; i++) { legs[i].attach(legPins[i]); legs[i].write(STAND); } pinMode(vacuumPin, OUTPUT); pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); digitalWrite(vacuumPin, HIGH); // vacuum runs while OctoBot moves } long readDistanceCM() { digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); long duration = pulseIn(echoPin, HIGH, 20000); return duration * 0.034 / 2; } // Tripod gait: legs 0,3,5,6 move together, then 1,2,4,7 void walkStep(bool climbing) { int liftAngle = climbing ? LIFT - 20 : LIFT; // lift extra high on stairs int groupA[] = {0,3,5,6}; int groupB[] = {1,2,4,7}; for (int i = 0; i < 4; i++) legs[groupA[i]].write(liftAngle); delay(150); for (int i = 0; i < 4; i++) legs[groupA[i]].write(STEP); for (int i = 0; i < 4; i++) legs[groupB[i]].write(liftAngle); delay(150); for (int i = 0; i < 4; i++) legs[groupA[i]].write(STAND); for (int i = 0; i < 4; i++) legs[groupB[i]].write(STEP); delay(150); for (int i = 0; i < 4; i++) legs[groupB[i]].write(STAND); delay(150); } void loop() { long distance = readDistanceCM(); // A stair edge shows up as a sudden jump in distance bool stairDetected = (distance > 15 && distance < 40); walkStep(stairDetected); }
STAND, LIFT, and STEP to see how the walking style changes, or add a button to turn the vacuum motor on and off separately from walking.Frequently asked questions
Is this project safe for kids to build?
Yes, with a grown-up helping — especially for cutting the chassis, gluing parts, and connecting the battery. The voltages involved (under 8V) are low, but adult supervision is still recommended.
Do I need to know how to code already?
No. The sketch above is ready to upload as-is. Learning happens by changing small numbers (like the angles) and watching what happens — that's how real engineers experiment too.
Why 8 legs instead of 6?
Six legs (a "hexapod") is a classic beginner design, but 8 legs give OctoBot extra stability and stronger grip on stair edges, similar to how a real octopus or spider distributes its weight.
Can it actually replace a store-bought robot vacuum?
Not quite — store-bought vacuums are more powerful and polished. OctoBot is a learning project designed to teach robotics, electronics, and code through a fun, hands-on build.
Comments
Post a Comment