# Hybrid Quadruped Robot
I designed and built this robot to walk on four legs and drive on four wheels. An Arduino Nano ESP32 controls twelve leg servos through a PCA9685 and four DC wheel motors through two TB6612 drivers.
My work included the mechanical design, power distribution, servo calibration, adapting the AVR servo update loop to a FreeRTOS task, and integrating wheel control and an ESP-NOW gamepad link. The walking code builds on work by SunFounder, Regis Hsu and Anuchit; their original credits remain in the legacy source.
Current green robot, with the leg assemblies, wheels and wiring visible.
## Code
Open each sketch separately in Arduino IDE, keeping its folder and `.ino` filename together.
| Folder | Contents |
| --- | --- |
| [firmware/spider_servo_only](firmware/spider_servo_only/) | ESP32 walking port with a FreeRTOS servo task. `CONTROL_MODE` selects ESP-NOW joystick control (default), USB serial commands or automatic walking. Servo-only: no wheel control. |
| [legacy/avr/spider_robot](legacy/avr/spider_robot/) | Earlier combined walking and wheel sketch, using AVR `FlexiTimer2` and `SerialCommand`. |
| [tools/i2c_scanner](tools/i2c_scanner/) | Scan the I2C bus for the PCA9685. |
| [tools/servo_90](tools/servo_90/) | Centre all PCA9685 channels before fitting servo horns. |
| [tools/hardware_test](tools/hardware_test/) | Test individual servos and bounded motor bursts over serial. |
| [tools/servo_calibration](tools/servo_calibration/) | Adjust reference-angle pulse counts and print the calibration table. |
The ESP32 sketches need the appropriate Arduino board package, `Wire` and, except for the scanner, Adafruit PWM Servo Driver. Joystick mode also needs rtlopez's `espnow-rclink` with `EspNowRcLink/Receiver.h` available. The legacy sketch needs AVR board support, `FlexiTimer2`, `SerialCommand`, `Wire` and Adafruit PWM Servo Driver. Serial speed is 115200 baud for the ESP32 sketches and 9600 for the legacy sketch.
Check each sketch's pin map against the board and wiring; the tools refer to both Nano ESP32 and Waveshare ESP32-S3-Nano boards. Use a separate servo supply with common ground, support the robot for motor tests, and calibrate the inherited pulse table for the fitted servos. The hardware tester's `x` command is processed after blocking motor bursts, so it is not an immediate stop.
## Build photos
Current robot held upright, showing the leg joints and wheels.
V1: the earlier purple four-legged build.