Balancing Roboduino

I finally got my Roboduino. The soldering was pretty straight forward. The only change I made was to replace the 3 pin header for power to a 2 pin Molex to match the one I have on the battery wires. Then I noticed there is no power switch! Oh well, I will use the power selection jumper instead. But the servos are directly connected to the battery, so make sure I don’t forget to unplug it when I don’t use the robot.

Then I wanted to test the board, so I unplugged the sensors and servos from my Balancing robot and plugged them into Roboduino. I didn’t screw the board to the robot, just let it hang over my old board. I had to put a piece of paper under Roboduino to make sure there are no unwanted shorts with the parts on the board underneath it. I also had to make a few changes to the code, because I plugged the servos and sensors into different pins. I loved the fact that the Rx and Tx pis are brought to 3 pin headers with power and ground, my serial LCD needs only the Tx pin, power and ground! Just plugged it like a sensor! Wonderfull!

Installing drivers for the USB FT232 was also easy, just followed the instructions on the Arduino website. I selected the Arduino Decimilla board and COM4 instead of COM1 and the code downloaded flawlessly. Ok, now let’s test it!

It works! Well, of course it works. Roboduino is a perfect little board. I’ve taken a couple pictures and a short video for you to see:





Edit: I have created a tutorial page to show you how you can build your own Balancing Roboduino!


About Gabriel (Ro-Bot-X)

Robots, nature, bees, and gardening, how do they mix together? After too much indoor activities one needs to get out and breathe! Harvest natural energy and create a little paradise. And ask the robots to help, of course.
This entry was posted in Eric, the butler robot. Bookmark the permalink.

13 Responses to Balancing Roboduino

  1. Stevo says:

    Balancing Roboduino,

    Were can I get your parts list and code from?
    Is it on this website somewhere?
    This looks like my perfect first project.


  2. Nash says:

    Hi there…I would like to know if you are willing to sell the balancing robot..How much are you willing to let go of it…

  3. robotxro says:

    Hi guys, thanks for your comments and interest.

    I can’t sell this robot (I reused the parts), but I can build another similar robot and give you a head start with the code. Now the code is not perfect, it needs more work to be perfect and also to be able to drive around, but that will be your part to do. I can use the last PCB from a batch of 10 pieces that I made a few years back that is compatible with Arduino software and not the Roboduino board, unless you order one yourself. The price for a similar robot all built with the Ro-Bot-X board, servos, Ping sensor, battery box, pot and chassis would go around US $150. That would include my work on it, not just a kit of parts. All mounted and programmed.

    By the way, this is the program that I was using:

    /* Balancing robot – on Roboduino
    – uses 2 modified servos for balancing
    – uses a potentiometer to adjust the perfect balance point
    – uses one Ping))) ultrasonic sensor to read the distance to the surface
    – uses a PID control algorithm to adjust the servo pulses so the Ping)))
    sensor reading will match the value of the perfect balance point

    #define PingPin 8 // digital pin 8 use 7 on Ro-Bot-X board)
    #define PotPin 0 // analog pin 0

    #define Lservo 6 // digital pin 6, PWM pin (use 4 on Ro-Bot-X board)
    #define Rservo 5 // digital pin 5, PWM pin

    #define Led 13 //digital pin 13
    #define Speaker 12 //digital pin 12 (use 13 on Ro-Bot-X board)

    unsigned int Ptime = 0; // raw value from sensors
    int Drive = 0; // PWM value sent to Servos
    int Error[5]; // array of 5 Error elements
    int P = 0; // proportional term
    int I = 0; // integral term
    int D = 0; // derivative term
    int SetPoint = 307; // perfect balance point value
    byte Count = 0; // counter
    int Period = 0; // period for generating sounds
    int Lwheel = 0; // left wheel variable
    int Rwheel = 0; // right wheel variable
    int Pot = 0; // potentiometer variable

    //tests should be made to determine acurate Min, Mid and Max values for the servos
    #define Midl 1460 // center for servos, they should be stoped
    #define Midr 1460

    //Ping PID constants
    #define Kp 3
    #define Ki 3
    #define Kd 4

    //Meaningful names for error array index:
    #define Current 0
    #define Sum 1
    #define Last 2
    #define SecondToLast 3
    #define Delta 4

    void setup() {

    pinMode(PingPin, OUTPUT);
    digitalWrite(PingPin, LOW);

    pinMode(Speaker, OUTPUT);
    digitalWrite(Speaker, LOW);

    pinMode(Lwheel, OUTPUT);
    digitalWrite(Lwheel, LOW);
    pinMode(Rwheel, OUTPUT);
    digitalWrite(Rwheel, LOW);

    delay(2000); //wait 1 second before start for debug purposes

    Serial.begin (9600);
    Serial.print(“Ping)) balancing”); // print in the first LCD line
    Serial.print(2, BYTE); // print in the second LCD line
    Serial.print(5, BYTE); // start from the fifth position
    Serial.print(“robot”); // text to print

    delay(100); //wait a little


    void loop(){
    delay(5); //wait 10 miliseconds, adjust this value for a 18 to 20 ms loop

    int Read_Pot_Sensor() {
    Pot = analogRead(PotPin);
    //Serial.print (“Pot = “); // debug – remember to comment out
    //Serial.println (Pot, DEC); // debug – remember to comment out
    return Pot;

    int Read_Ping_Sensor() {
    //trigger the sensor
    pinMode(PingPin, OUTPUT);
    digitalWrite(PingPin, LOW);
    digitalWrite(PingPin, HIGH);
    digitalWrite(PingPin, LOW);
    //receive the echo
    pinMode(PingPin, INPUT);
    digitalWrite(PingPin, HIGH); // turn on pull up resistor
    Ptime = pulseIn(PingPin, HIGH);
    Serial.print(1, BYTE); // print in the first LCD line
    Serial.print(1, BYTE); // start from the first position
    Serial.print(“Ping: “); // text to print
    Serial.print(Ptime, DEC); // variable to print
    return Ptime;

    int PID() {
    //Error[Current] = SetPoint – Ptime;
    Error[Current] = Pot – Ptime;
    P = Error[Current] * Kp;
    Error[Sum] = Error[Current] + Error[Last] + Error[SecondToLast];
    I = Error[Sum] * Ki;
    Error[Delta] = Error[Current] – Error[Last];
    D = Error[Delta] * Kd;
    Drive = P + I + D;
    Error[SecondToLast] = Error[Last];
    Error[Last] = Error[Current];
    //Drive = Drive * 4; // we have to multiply the result to get in the 1000-2000 interval
    Serial.print(2, BYTE); // print in the second LCD line
    Serial.print(1, BYTE); // start from the first position
    Serial.print(“PID: “); // text to print
    Serial.print(Drive, DEC); // variable to print
    return Drive;

    void Drive_Motors() {
    Lwheel = Midl + Drive;
    digitalWrite(Lservo, HIGH);
    digitalWrite(Lservo, LOW);
    //Serial.print (“Left = “); // debug – remember to comment out
    //Serial.println (Lwheel, DEC); // debug – remember to comment out

    Rwheel = Midr – Drive;
    digitalWrite(Rservo, HIGH);
    digitalWrite(Rservo, LOW);
    //Serial.print (“Right = “); // debug – remember to comment out
    //Serial.println (Rwheel, DEC); // debug – remember to comment out

    void Clear_LCD() {
    Serial.print(5, BYTE); // select LCD command mode
    Serial.print(1, BYTE); // clear screen

    • al says:

      Hi, wondering if you can help me design a roboduino that will push a swing, either by a robot arm or a robot that sits on the swing and swings itself like a child on a swing. thanks for any help ! Al

      • robotxro says:

        If I were here to help everyone that asked me to help them build their robot, I would not have time for myself and my projects. Keep in mind that I have a full time job, a family to take care and only then, if I have time, I am working on my hobby, either by working on my robot, or doing research, or surveying the forums. Once in a while I write something worth mentioning here.

        So, to answer your question, no, I can’t help you. To get help, please go to a robotic forum, like SocietyOfRobots or Let’sMakeRobots where you can post your questions and anyone available that has the knowledge will answer them.

        If you have questions related to the robots I have built, you can ask here, but I can’t teach you how to build yours. Each robot is different, lots of work has to be done by the builder itself. So, good luck to you and your project!

  4. Nash says:

    Can i have your email so that i can contact you…

  5. Nash says:

    I would love to get one from you..You can help me start building it now..Just let me know how should i pay you…a direct contact would be helpful…hope to hear from you soon..My contact would be

  6. JJ says:

    Hi, I was just wondering what kind of servos you used.

    • robotxro says:

      I used Futaba S3004 servos that I modified for continuous rotation. Same servos are allready modified by Parallax, you can get them on their website.

  7. haz____na says:

    I am doing 2nd year mechanical engineering in chennai(India)
    I would like to do this as my project in my college
    Can you help me please?????
    Where can I get your parts list

  8. Droidbuilder says:

    Have you taken this any further, like a remote control or autonomous driving around or something?

    You should post this bot in LMR… 🙂

    • robotxro says:

      Unfortunately I sold the robot to a guy in Australia, I think he needed it for a school project or so. Anyway, there are a few problems with this setup, first, the servos can’t recover fast enough from a fall, speedier motors should be used, and second, the Ping sensor readings are not linear, they jump up or down, depending on the angle the sensor is at. So the robot is not stable more than a few seconds. Because of this reason, I could not make it to drive around.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s