Robotics EveryDay
Published © GPL3+

Wheeled Self-Balancing Robot | Arduino L293D & HC SR-04

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

BeginnerFull instructions provided7,207
Wheeled Self-Balancing Robot | Arduino L293D & HC SR-04

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Dual H-Bridge motor drivers L293D
Texas Instruments Dual H-Bridge motor drivers L293D
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Geared DC Motor, 12 V
Geared DC Motor, 12 V
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
9V 1A Switching Wall Power Supply
9V 1A Switching Wall Power Supply
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)
Wheels for geared dc motor
PVC Pipes
PVC T-Joint
PVC Elbow Joint

Story

Read more

Custom parts and enclosures

CAD Design of Wheeled Self Balancing Robot

Schematics

Circuit Schematic Of Wheeled Self Balancing Robot

Code

CAD Design For Wheeled Self Balancing Robot

Arduino
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);
  }


}

Credits

Robotics EveryDay

Robotics EveryDay

0 projects • 9 followers

Comments