Introduction: Wheeled Self-Balancing Robot | With Arduino Uno, L293D & Ultrasonic Sensor | Self Balancing Robot Without IMU (MPU-6050) | Arduino Two Wheel Robot

This is a wheeled self-balancing robot. Powered by Arduino UNO and balanced by ultrasonic sensor. It is able to balance itself vertically.

Supplies

  • Arduino Uno x1
  • Geared DC motor with Wheels x2
  • L293D Motor Driver IC x1
  • Ultrasonic Sensor (HC SR-04) x1
  • Power Supply x1
  • PVC Pipes 1 meter
  • PVC T-Joint x1
  • PVC Elbow Joint x1
  • Breadboard x1
  • Connecting Wires

Step 1: Geared DC Motor

We will be using two geared dc motors to power this robot.

Step 2: Attaching Wheels to Geared DC Motor

Now we will attach wheels to the shafts of the motors.

Step 3: PVC T-Joint

This is a T-joint for PVC pipe. We will be using it to hold the motors. The wires will come out from the top hole. 

Step 4: Wiring Motors Through T-joint

Before fixing the motor in this pipe, we have to wire them. We will be passing 4 wires from the top hole. Splitting at two ends, 2 wires for each motor.

Step 5: Pulling Wires Through Top Hole

We will pull the wire from T-joint back so that the motors will be in their place. 

Step 6: Fixing Motors in Place

Now we have fixed the motor in the T-joint. 

Step 7: Adding Pipes in Top Hole to Mount Ultrasonic Sensor

We have added some pipes at the wire end of the T-Joint. We will mount the sensor on it later.

Step 8: Circuit Schematic

Here is the Circuit Schematic. We have used L2938 H bridge motor driver IC to rotate motors in both directions.

Step 9: Concept of the Self Balancing Robot

The concept for this self-balancing robot is simple. Here we have an ultrasonic sensor. Which measures its distance from the obstacle in front of it.

if the distance is greater than the fixed distance then the robot will move forward and if the distance is less, then the robot will move reverse. to compensate for its fall.

Step 10: Wiring Ultrasonic Sensor With Arduino for Self Balancing Robot

The ultrasonic sensor has 4 pins, which are trigger, echo, power, and ground. 4 wires are connected from the pins to microcontroller.

Step 11: Watching the Robot Balance Itself

Now, the robot is placed vertically on the ground. And it seems like, it is balanced. It is moving continuously to keep itself balanced.

But, it is also getting some support from the wires, which I am holding in my hand.

It is oscillating back & forth continuously, these oscillations need to be damped. So, the robot will be balanced and stand at a point without any movement.

Step 12: Issues & Resolutions in Self Balancing Robot

If it falls beyond a particular point, then it won't be able to recover itself.

These motors require a lot more power to be fast and responsive.

And while testing, the second H-bridge of the L293D got fried. So, I didn't get the chance to control it via PID.

To truly make it balanced, we could have used the MPU-6050 Inertial measurement unit. Instead, we used this cheap ultrasonic sensor.

Step 13: CAD Design of the Self Balancing Robot

This is the CAD, design of the wheeled self-balancing robot. Here we can see two motors, connected with two wheels. These motors are mounted in the PVC T-joint. a vertical PVC pipe is attached to T-joint. An ultrasonic sensor is attached to the pipe. Pointing downwards.

Step 14: View CAD Design of Wheeled Self Balancing Robot

Step 15: Conclusion

But, somehow we managed to make it balanced a little bit. We are happy with the results. 


Robotics EveryDay!!!

Step 16: Code for the Self Balancing Robot


int ip3=2,ip4=3;
int t=8,e=9;


void setup() {
  pinMode(t, OUTPUT);  //trigger pin
  pinMode(e, INPUT);  //echo pin
  
  pinMode(ip3,OUTPUT);
  pinMode(ip4,OUTPUT);


}


float distance(){
  
  float duration, cm;
  
  digitalWrite(t, LOW);
  delayMicroseconds(2);
  digitalWrite(t, HIGH);
  delayMicroseconds(5);
  digitalWrite(t, LOW);
  
  duration = pulseIn(e, HIGH);


  cm = duration/ 29 / 2;
  
  return cm; //returns distance in centimeters
}


void loop() {
  
  float dis = distance();


  if (dis>27){
    digitalWrite(ip3,LOW);
    digitalWrite(ip4,HIGH);
  
  }else if(dis<27){
    digitalWrite(ip3,HIGH);
    digitalWrite(ip4,LOW);
  }


}



Trash to Treasure Contest

Participated in the
Trash to Treasure Contest