A highly versatile modular snake robot with multiple locomotion gaits, powered by ESP32 and controlled via Bluepad32 gamepad integration. This project demonstrates various biomimetic snake motions including serpentine movement, rolling, sidewinding, and concertina motion.
Watch the full demonstration: Snake Robot in Action
![]() |
![]() |
![]() |
![]() |
- Multiple Locomotion Gaits: Serpentine, rolling, sidewinding, concertina, and more
- Gamepad Control: Real-time control using Bluepad32 library
- Modular Design: 10-11 servo configuration with 2 DOF per module
- Sensor Integration: VL53L0X ToF sensors for depth analysis and obstacle detection
- Autonomous Navigation: Path following and hole detection capabilities
- Three Generations: Continuous hardware and software improvements
- Microcontroller: ESP32 (13, 12, 14, 27, 26, 25, 33, 32, 21, 19, 22 GPIO pins)
- Servos: 10-11 servos (alternating vertical and horizontal planes)
- Sensors: 5x VL53L0X Time-of-Flight distance sensors
- Control: Bluetooth gamepad via Bluepad32
- Power: Regulated power supply for servos and ESP32
Classic snake-like forward movement using sinusoidal wave propagation.
Code: snake-serpent/snake-serpent.ino
// Sinusoidal wave parameters
float Wavelengths = 1.5;
int amplitude = 50;
float Speed = 2;Videos:
- [Serpentine Motion (1st Gen)](Videos/1st_Generation/Serpentile motion .mp4)
- [Straight Motion Simulation (3rd Gen)](Videos/3rd_Generation/straigh motion simulation.mp4)
- [Path Following](Videos/3rd_Generation/path following.mp4)
Coordinated rolling movement for traversing obstacles and changing direction.
Code: snake-roll-jump/snake-roll-jump.ino
Videos:
- [Rolling Motion (2nd Gen)](Videos/2nd_Generation/Rolling motion.mp4)
- [Rolling Motion Trial (3rd Gen)](Videos/3rd_Generation/rolling motion trial.mp4)
- [Rolling Motion Full (3rd Gen)](Videos/3rd_Generation/rolling motion.mp4)
Lateral undulation inspired by sidewinder rattlesnakes, ideal for sandy terrain.
Code: cmu-2/cmu-2.ino | cmu-side-winding/cmu-side-winding.ino
Videos:
- CMU Motion (1st Gen)
- [Side Sliding Motion (1st Gen)](Videos/1st_Generation/side sliding motion.mp4)
Basic linear movement with two-loop implementation.
Code: forward-moving-two-loops/forward-moving-two-loops.ino | back/back.ino
Videos:
- [Forward Motion (2nd Gen)](Videos/2nd_Generation/Forward Motion.mp4)
- [Backward Motion (2nd Gen)](Videos/2nd_Generation/Backward motion.mp4)
Continuous circular head movement and full circular path navigation.
Code: t-move/t-move.ino
Videos:
- [Circular Head Motion (1st Gen)](Videos/1st_Generation/circular head .mp4)
- [Circle Motion (3rd Gen)](Videos/3rd_Generation/circle motion.mp4)
- [Curve Path Motion](Videos/3rd_Generation/curve path motion simulation.mp4)
Advanced motion for navigating through confined spaces and holes.
Code: tunnel-moving/tunnel-moving.ino | itself-winding/itself-winding.ino
Videos:
- Hole Detection (1st Gen)
- [Hole Motion (3rd Gen)](Videos/3rd_Generation/hole motion.mp4)
- [Hole Motion Full (3rd Gen)](Videos/3rd_Generation/hole motion full.mp4)
Real-time depth sensing and environment analysis using ToF sensors.
Videos:
- [Depth Analysis (1st Gen)](Videos/1st_Generation/Depth Analysis.mp4)
- [Depth Analysis 2 (1st Gen)](Videos/1st_Generation/depth analysis_2.mp4)
Complete wireless control with customizable commands.
Code: controller-commands/controller-commands.ino | command-new/command-new.ino | command-snake/command-snake.ino
# Arduino IDE or PlatformIO
# ESP32 Board Package
# Required Libraries:
- ESP32Servo
- Bluepad32
- Wire (I2C)
- VL53L0X
- Adafruit_PWMServoDriver- Clone this repository:
git clone <your-repo-url>
cd Motions-
Install required libraries in Arduino IDE:
- Sketch โ Include Library โ Manage Libraries
- Search and install: ESP32Servo, Bluepad32, VL53L0X, Adafruit PWM Servo Driver
-
Select Board:
- Tools โ Board โ ESP32 Arduino โ ESP32 Dev Module
-
Upload desired motion code:
- Open any
.inofile from the motion folders - Select correct COM port
- Upload
- Open any
-
Servo Connections:
- Servo 0: GPIO 13
- Servo 1: GPIO 12
- Servo 2: GPIO 14
- Servo 3: GPIO 27
- Servo 4: GPIO 26
- Servo 5: GPIO 25
- Servo 6: GPIO 33
- Servo 7: GPIO 32
- Servo 8: GPIO 21
- Servo 9: GPIO 19
- Servo 10: GPIO 22
-
I2C Sensors (VL53L0X):
- SDA: GPIO 4
- SCL: GPIO 5
- Multiple sensors with address multiplexing (GPIO 15, 2, 18, 23)
Motions/
โโโ snake-serpent/ # Serpentine locomotion
โโโ snake-roll-jump/ # Rolling motion
โโโ cmu-2/ # CMU sidewinding implementation
โโโ cmu-side-winding/ # Alternative sidewinding
โโโ forward-moving-two-loops/ # Forward motion
โโโ back/ # Backward motion
โโโ controller-commands/ # Main gamepad control system
โโโ command-new/ # Updated command interface
โโโ command-snake/ # Snake command wrapper
โโโ t-move/ # Circular/turning motion
โโโ tunnel-moving/ # Tunnel navigation
โโโ itself-winding/ # Self-winding motion
โโโ Photos/ # Hardware images
โโโ Videos/ # Motion demonstrations
โโโ 1st_Generation/ # Early prototype videos
โโโ 2nd_Generation/ # Improved design videos
โโโ 3rd_Generation/ # Latest generation videos
- Initial motion calibration
- Basic serpentine and sidewinding
- Depth analysis implementation
- Proof of concept for hole navigation
Videos: Videos/1st_Generation/
- Improved rolling mechanics
- Forward and backward motion refinement
- Better servo synchronization
Videos: Videos/2nd_Generation/
- Path following capabilities
- Advanced curve navigation
- Hole detection and navigation
- Motion simulation improvements
Videos: Videos/3rd_Generation/
When using controller-commands/controller-commands.ino:
- Left Stick: Manual servo control
- Right Stick: Speed adjustment
- D-Pad: Preset motion selection
- Buttons: Mode switching and calibration
int amplitude = 50; // Wave amplitude (degrees)
float Wavelengths = 1.5; // Number of waves along body
float Speed = 2; // Movement speedint offsets[] = {0, 45, 90, 135, 180, 225, 270, 315, 360, 405, 450};// Adjust distance thresholds in controller-commands.ino
// Variables: a, b, c, d, e (sensor readings)- Speed: Variable (configurable via code)
- Servos: 10-11 DOF
- Sensor Range: VL53L0X (up to 2m)
- Control Latency: ~50ms (Bluetooth gamepad)
- Power: 5V servo power + 3.3V ESP32
Contributions are welcome! Feel free to:
- Report bugs
- Suggest new motion gaits
- Improve existing code
- Add documentation
This project is open-source. Please provide attribution when using or modifying the code.
- Carnegie Mellon University (CMU) for sidewinding algorithms
- Bluepad32 library developers
- Arduino and ESP32 community
- VL53L0X sensor integration examples
For questions or collaborations, please open an issue in this repository.
โญ If you find this project interesting, please star the repository!
- [Calibration 1](Videos/1st_Generation/Motion calibration_1.mp4)
- [Calibration 2](Videos/1st_Generation/Motion calibration_2.mp4)
- [Calibration 3](Videos/1st_Generation/Motion calibration_3.mp4)
- [Calibration 4](Videos/1st_Generation/motion calibration_4.mp4)
- [Path Following Full Trial](Videos/3rd_Generation/path following full trial.mp4)
- [Path Following Curve](Videos/3rd_Generation/path following curve .mp4)




