How to build a self balancing robot
Aim: Build a two wheel self balancing robot with arduino. Similar to the segway, uses control theory such as the inverted pendulum
Hardware used: 1 x arduino Duemilove, 1 x ardumoto, 1 x 8.4v 1400maH battery, 1x adxl203adxrs614 IMU. All these components are available at sparkfun
Misc: 2x tamiya dc motor, twin tamiya gearbox.
Step 1: Things you need
Motordriver: Ardumoto from Sparkfun
Microcontroller: Arduino Duemilove
Tamiya Twin Gearbox & 2 x DCmotor
You can choose to use the normal AA battery or any other battery, arduino can takes in max 12v
Sketch where you want to put all your components, make a design that is small and easy to balance.The battery is the heaviest, therefore I place it at the most bottom to lower the centre of gravity, I place the motor driver at the top because it is hottest. Accelerometer and gyro should be placed near the centre of the device to make the reading more accurate.
Step 2: Connect up the wires, Solder the connector to ardumoto and plug it on top of arduino
2) Connect the motors to the ardumoto.You may refer to this tutorial on how to use ardumoto with arduino http://www.sparkfun.com/tutorials/195.
3) Connect the battery to the 9v jack of arduino. You may also add an on/off switch in between it.
Note: the 9v jack and USB of arduino run separately, if you just connect the USB, only the arduino logic circuit will be powerup, the motor will not run. If you connect the 9v Jack to the battery pack, both arduino and motor will run.
Step 3: Software
You need to download arduino bootloader to your computer in order to program arduino, Please refer to this tutorial on how to install arduino bootloader. http://workshopdiy.blogspot.com/2011/05/how-to-install-arduino.html
Step 4: Download the code
Download the code given here and try run it. You need to tune the PD value in order to get the device stable