Introduction: Rollbars for Self Balancing Robot and on Stairs

About: I am an American teaching English at Shangluo University, Shaanxi. I like making machines that do interesting but fairly useless things - I call them Quixotic Machines.

Added some rollbars made from badminton rackets to my simple self balancing robot which falls over quite a bit. Now at least it can get back up most of the time.

I am sorry in that I am not creating a real build instructable because this is really a poor excuse for a balancing robot - it was more of a test platform for some ideas. I am using 60rpm continuous servos which are really too slow for self-balancing, the only reason they work is because of the unusually large wheels. You really need geared motors with a couple hundred rpm. The sensor I am using is a VTI ASCA610 inclinometer accelleromter. Probably unusual in USA but common and cheap here in china.

The only other piece of hardware is an Arduino UNO. The program is supersimple! Only two IF statements to control the servos, which are always on in one direction or the other, no PID control - this is called bang-bang control.

Here is the program: (sorry about formatting)

#include <servo.h>
Servo myservo1; // create servo object to control a servo Servo myservo2; int potpin = 0; // analog pin used to connect the potentiometer int val; // variable to read the value from the analog pin int gyroPin = 1; int gyroVal = 0; int gyroAvg = 0; void setup() { myservo1.attach(11); // attaches the servo on pin 11 to the servo object myservo2.attach(9); // other wheel myservo1.writeMicroseconds(1500); delay(15); myservo2.writeMicroseconds(1500); delay(15); Serial.begin(9600); Serial.println("Program begin..."); } void loop() { val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023) val = map(val, 0, 1023, 0, 1000); // scale it to use it with the servo (value between 0 and 100) gyroVal = analogRead(gyroPin); //gyroVal = map(gyroVal, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180) gyroAvg = analogRead(gyroPin) + analogRead(gyroPin) + analogRead(gyroPin) ; gyroVal = gyroAvg / 3; //if (gyroVal > (val - 10) and gyroVal < (val + 10)) { myservo1.writeMicroseconds(1500); myservo2.writeMicroseconds(1500); } //else if (gyroVal > (val -15) and gyroVal <= (val - 10)) { myservo1.write(110); myservo2.write(0); } if (gyroVal > (0) and gyroVal < (val )) { myservo1.write(180); myservo2.write(0); } //else if (gyroVal > ( val + 10) and gyroVal <=(val + 15)) { myservo1.write(0); myservo2.write(110); } else if (gyroVal > ( val ) and (gyroVal < 800)) { myservo1.write(0); myservo2.write(180); } Serial.print(" pot: ");Serial.print(val);Serial.print(" angle: ");Serial.println(gyroVal); //myservo.write(val); // sets the servo position according to the scaled value delay(10); // }