Defying gravity, one PID loop at a time
Meet the Self-Balancing Bot - a two-wheeled marvel that refuses to fall over! This isn't just another robot; it's a testament to the beautiful dance between physics, mathematics, and engineering. Using the magic of PID control and the precision of a BNO055 IMU, this little warrior constantly fights gravity and wins.
Our bot thinks fast and acts faster:
- ๐๏ธ PID Controller: The secret sauce that keeps things upright
- ๐ก BNO055 IMU: 9-axis absolute orientation sensor providing real-time feedback
- ๐ง Arduino Nano: The compact powerhouse processing it all
- ๐ฏ Closed-Loop System: Continuous feedback for perfect balance
| Component | Specification |
|---|---|
| Microcontroller | Arduino Nano |
| IMU Sensor | BNO055 9-DOF Absolute Orientation |
| Control Algorithm | PID (Proportional-Integral-Derivative) |
| Communication | I2C (IMU โ Arduino) |
| Balance Range | adjust what your bot physics sypports ! |
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ BNO055 โโโโโถโ Arduino Nano โโโโโถโ Motors โ
โ IMU Sensor โ โ PID Control โ โ & Wheels โ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โฒ โ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโ Tilt Angle โโโโโโโโโโโโโโ
โ Feedback โ
โโโโโโโโโโโโโโโโ
- Sense: BNO055 measures the bot's tilt angle and angular velocity
- Think: Arduino calculates the error using PID algorithm
- Act: Motors adjust wheel speed to counteract the tilt
- Repeat: Loop runs continuously at high frequency
- Balance: Bot maintains upright position like a digital tightrope walker
- ๐ช Dynamic Balance: Recovers from disturbances automatically
- ๐ Real-time Processing: Sub-10ms response time
- ๐ Sensor Fusion: BNO055's built-in Kalman filter for smooth data
- ๐๏ธ Tunable Parameters: Adjustable PID gains for optimal performance on your own bot
- ๐ง Compact Design: Nano form factor for minimal footprint
| Qty | Component | Purpose |
|---|---|---|
| 1 | Arduino Nano | Main controller |
| 1 | BNO055 IMU Module | Orientation sensing |
| 2 | n20 Geared Motors | Propulsion |
| 2 | n20 Wheels | Ground contact |
| 1 | Motor Driver (TB6612FNG) | Motor control |
| 1 | liPo | Power source |
| 1 | Chassis/Frame | Mechanical structure |
| - | Jumper Wires & Headers | Connections |
Arduino Nano BNO055 IMU
VIN โโโโโโโโโโโโ VCC
GND โโโโโโโโโโโโ GND
A4 โโโโโโโโโโโโ SDA
A5 โโโโโโโโโโโโ SCL
Arduino Nano Motor Driver
D3 โโโโโโโโโโโโ ENA
D4 โโโโโโโโโโโโ IN1
D5 โโโโโโโโโโโโ IN2
D6 โโโโโโโโโโโโ ENB
D7 โโโโโโโโโโโโ IN3
D8 โโโโโโโโโโโโ IN4
The art of balance lies in the PID parameters:
- Kp (Proportional): Start with 20-50, higher = more aggressive
- Ki (Integral): Usually small, 0.1-1.0, eliminates steady-state error
- Kd (Derivative): Start with 0.5-2.0, adds damping
- Set Ki and Kd to 0
- Increase Kp until oscillation begins
- Add Kd to reduce oscillation
- Add small Ki to eliminate offset
- AI Powered: Reinforcement Learning (NO magical PID!)
- Advanced Sensors: Camera for line following
- Machine Learning: Adaptive PID parameters
- LED Indicators: Visual status feedback
- Mount Arduino Nano and BNO055 on chassis
- Connect motors to H-bridge driver
- Wire according to pinout diagram above
- Install push button on pin 11 for initial calibration
- Install Adafruit BNO055 library in Arduino IDE
- Upload the provided code to Arduino Nano
- Open Serial Monitor (115200 baud) for debugging
- Power on the bot in upright position
- Wait for BNO055 auto-calibration (few seconds)
- Press calibration button to set balance point
- Observe angle readouts in Serial Monitor
- Adjust the three PID parameter sets in code
- Modify
motorMax,motorMinvalues for your motors - Change
startAnglefor different safety thresholds - Test in safe environment with crash protection!
- Place bot upright and watch the magic
- Gently push to test recovery response
- Monitor serial output for performance analysis
Found a bug? Have an improvement? Contributions are welcome! Whether it's:
- Code optimizations
- Documentation improvements
- Hardware modifications
- PID tuning suggestions
This project is open source - feel free to learn, modify, and share!
"In a world full of things that fall down, be the bot that stands up!" ๐คโ๏ธ
Made with โก Arduino, ๐งฎ Math, and โค๏ธ Engineering