Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

Quadruped Spider Robot

So I built this 4-legged walking robot using an ESP32 and a PCA9685 servo driver. The cool part? You don't need a 3D printer - just some basic craft materials. It's honestly a great project for learning how robots walk and balance.

What it does

The robot can walk forward and backward, turn left and right, and you control everything through serial commands. I added smooth motion so it doesn't look too jerky, plus there's a calibration mode in case your servos aren't perfectly aligned (spoiler: they never are).

What you'll need

Electronics stuff

  • ESP32 board (pretty much any variant works)
  • PCA9685 servo driver (get the Adafruit one or a cheap clone)
  • 12 hobby servos I used SG90s, they're like $2 each
  • A decent 5V power supply that can push at least 2-3 amps
  • Some jumper wires
  • Maybe a breadboard if you're prototyping

Building materials (the fun part - no 3D printer!)

You can basically use whatever you have lying around:

  • Thick cardboard works great (raid your recycling bin)
  • Popsicle sticks if you want it to look nice
  • Old plastic containers
  • Straws or skewers (for leg segments)
  • Hot glue gun + glue sticks
  • Zip ties or wire (for securing servos)
  • Tape, screws, or brass fasteners (for joints)

See ASSEMBLY.md for construction ideas.

Wiring basics

Here's the quick version - full diagrams are in WIRING.md if you need them.

ESP32 connects to PCA9685 like this:

| ESP32 Pin | PCA9685 Pin | What it does |\n|-----------|-------------|-------------|\n| 3.3V or 5V | VCC | Powers the board logic |\n| GND | GND | Ground |\n| GPIO 21 (SDA) | SDA | I2C data line |\n| GPIO 22 (SCL) | SCL | I2C clock line |

Servos go on channels 0-11:

Each leg has 3 servos (hip, upper leg, lower leg). Front Left uses channels 0-2, Front Right is 3-5, Back Left is 6-8, Back Right is 9-11.

Super important: Don't try to power the servos from the ESP32! You'll fry it. Use a separate 5V power supply connected to the V+ terminal on the PCA9685. Trust me on this one.

Getting the software set up

First, grab Arduino IDE

Just download it from arduino.cc if you don't have it already.

Add ESP32 support

  1. Open Arduino IDE
  2. File → Preferences
  3. Paste this into "Additional Board Manager URLs":
    https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
    
  4. Tools → Board → Board Manager
  5. Search "ESP32" and install it

Install the servo library

Go to Sketch → Include Library → Manage Libraries, then search for and install:

  • Adafruit PWM Servo Driver Library

That's it. The Wire library should already be there.

Upload the code

  1. Open quadruped_robot.ino
  2. Pick your ESP32 board from Tools → Board
  3. Pick your port from Tools → Port
  4. Hit the upload button

How to use it

Once you upload the code, open the Serial Monitor (set it to 115200 baud) and you can control the robot with these commands:

Command What it does
F Walks forward
B Walks backward
L Turns left
R Turns right
S Stops moving
N Goes back to standing position
C Opens calibration mode

Calibrating the servos

Look, cheap servos are never perfect. If your robot looks wonky when it stands up, here's how to fix it:

  1. Send C to enter calibration mode

  2. All servos will go to 90° (neutral position)

  3. Now you can adjust them:

    • Type 0-11 to pick which servo you want to adjust
    • Hit + to nudge it one way
    • Hit - to nudge it the other way
    • Type p to see all your current offsets
    • Type x when you're done
  4. Write down your offsets and put them in config.h so they stick around

Tweaking things

You can mess with a bunch of settings in config.h:

  • Servo pulse limits if your servos are different
  • How fast it walks (the delay timings)
  • Where the legs go when standing, lifting, walking
  • Permanent servo offset values

When things go wrong

Nothing's moving

  • Make sure your power supply is actually 5V and can handle at least 2 amps
  • Double-check the I2C wires (SDA to GPIO21, SCL to GPIO22)
  • The PCA9685 address should be 0x40 unless you changed it
  • Check the Serial Monitor - it might tell you what's wrong

Servos are jittery or making noise

  • You probably need more power - get a beefier 5V supply
  • Check for loose wires
  • Try adjusting SERVOMIN and SERVOMAX in the config file

Robot looks drunk (tipping over)

  • Use calibration mode to fix wonky servos
  • Make sure the servo horns are screwed on straight
  • Check that all the legs are about the same length
  • Move your battery around until it balances better

Servos going the wrong way

  • Just flip the offset in calibration mode
  • Or change the position values in config.h

What you'll learn from this

The robot walks using a "diagonal gait" - basically the front-left and back-right legs move together, then the front-right and back-left move. It's the same way dogs and horses walk, and it's pretty stable.

The code uses a state machine, which is just a fancy way of saying the robot knows what it should be doing (standing, walking, turning, etc.) and switches between those states.

What to build next

Once you get this working, here are some fun additions:

  • Stick an ultrasonic sensor on it so it doesn't run into stuff
  • Add speed control
  • Try different walking patterns (tripod gait, wave gait, etc.)
  • Add Bluetooth or WiFi so you can control it from your phone
  • Make it autonomous

Files in this project

hexapod/
├── quadruped_robot.ino    # The main code
├── config.h               # All the settings
├── README.md              # You're reading it
├── WIRING.md              # How to wire everything
└── ASSEMBLY.md            # How to build the body

That's pretty much it! Build something cool and don't be afraid to experiment with the code. If you break something, you can always re-upload it.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages