How to make a self balancing robot with arduino

 self-balancing robot is very popular nowadays and easy to make. in this blog post, you will learn how to make a self balancing robot with Arduino. you should have some knowledge of embedded c and hardware. you can find circuit as well as code for self-balancing robot in this post read carefully and follow the step to make self balancing robot. this self balancing robot have future  we can use this concept in our two-wheelers . and this can use in the mini projects for ece or best electronic projects for  final year 

How to make a self balancing robot with arduino


The concept of this project is very simple we use Accelerometer mount over the robot which gives the 3-axis value. accelerometer connected to the Arduino.  arduino collect data from the accelerometer and compare the value with the given condition. there are two conditions.

1.if robot tilt in forwarding direction accelerometer gives some value to the Arduino and Arduino give the instruction to the motor to move backwards

2. if robot tilt in backward direction accelerometer gives some another value to the Arduino. arduino, give instruction to move in forwarding direction.

Component Required for self balancing robot

  1. Accelerometer
accelerometer gives us a 3-axis value. it change the value when it tilt in any direction. for example, we tilt it in the x-axis it change the value in the x-axis and some for rest of two axis
accelerometer
  1. Arduino Uno
Arduino uno is an open source microcontroller and easy to use you can learn Arduino from Arduino tutorial.
  1. DC Motor
Dc motor with gear mostly use in robotic projects because of it’s torque
 
Interface Arduino with Accelerometer
 in this diargam you can see the connectrion clearly
Connection Diagram of Self balancing Robot.
All connection should be according to the diagram and your code. The diagram is very simple and easy to make. by this diagram, you can easily make self balancing robot with Arduino. follow these step to make connections
  • Connect Accelerometer Vcc and Gnd wires to the Arduino Vcc and Gnd Wires.
  • Connect Accelerometer X-axis to the Arduino Analog Pin A0
  • Connect Accelerometer Y-axis to the Arduino Analog Pin A1
  • Connect Accelerometer Z-axis to the Arduino Analog Pin A2
  • Connect Arduino digital Pin 6 to the IN1 of Motor Driver
  • Connect Arduino digital Pin 8 to the IN2 of Motor Driver
  • Connect Arduino digital Pin 9 to the IN3 of Motor Driver
  • Connect Arduino digital Pin 10 to the IN4 of Motor Driver
C Code for Self balancing robot 
 
void setup() {
pinMode(6,OUTPUT);
pinMode(8,INPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(A1, INPUT_PULLUP);
pinMode(A2, INPUT_PULLUP);
pinMode(A0,INPUT_PULLUP);
 
}
void loop() {
 
 
  int m= analogRead(A0);
  if(m==XXX) //calibrate your accelerometer and findout the value when your bot is tilt forward 
  {
    digitalWrite(6, HIGH);
    digitalWrite(8, LOW);
    digitalWrite(9, HIGH);
    digitalWrite(10, LOW);
    
    }
 
else if(m==XXX) //calibrate your accelerometer and findout the value when your bot is tilt backward 
  {
    digitalWrite(6, LOW);
    digitalWrite(8, HIGH);
    digitalWrite(9, LOW);
    digitalWrite(10, HIGH);
    
    }
else 
 
   {
    digitalWrite(6, LOW);
    digitalWrite(8, HIGH);
    digitalWrite(9, LOW);
    digitalWrite(10, HIGH);
    
    }
}  
 
copy this code into Arduino IDE and upload in your Arduino Uno and then do connection your self balancing robot will working.
How to make a self balancing robot with arduino /self balancing robot with arduino/tutorial self balancing robot with arduino/  self balancing robot with arduino tutorial

7 thoughts on “How to make a self balancing robot with arduino

  • April 5, 2019 at 4:48 pm
    Permalink

    Hi
    Why does the first picture show an ADXL362 accelerometer, then a the second picture shows an ADXL335 type?
    The code then makes a very feeble attempt at defining a robot balancing 'algorithm'.
    There is no way balance can be achieved with such a basic, incomplete implementation.

    Is this all the code there is? – surely not!

    John

    Reply
    • May 29, 2019 at 1:37 pm
      Permalink

      Anyone Help me to easily Calibrate ADXL335 sensor

      Reply
      • May 30, 2019 at 4:46 am
        Permalink

        yes connect your ADXL sensor to the Analog pins of the arduino and try to get input value from the adxl335 and print this value on the seria;l monitor. now you have to tilt the sensor and the variation in data noted. now according to your bot give condition on the values.

        Reply
  • June 11, 2019 at 7:13 am
    Permalink

    Great weblog here! Additionally your web site lots up fast! What host are you using? Can I am getting your associate link in your host? I desire my website loaded up as quickly as yours lol

    Reply
  • June 11, 2019 at 8:19 am
    Permalink

    Thanks for the good writeup. It if truth be told was a leisure account it. Glance complex to far introduced agreeable from you! By the way, how can we be in contact?

    Reply
  • June 12, 2019 at 8:28 am
    Permalink

    I savour, cause I discovered just what I was taking a look for. You’ve ended my 4 day long hunt! God Bless you man. Have a great day. Bye

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *