How to Make Table Edge Avoiding Robot || #MadeWithArduino

How to Make Table Edge Avoiding Robot || #MadeWithArduino

6 min read
Quick Navigation
This car uses a very working principle that is as follows: ~ When the car reaches the end of the table i.e. the edge of the table the ultrasonic sensor detects its depth of it and it makes the car go back.

Hey Guys, welcome to my article. So guys today we are going to make a " Table Edge Avoiding Robot ".

Let me first tell you about the main working principle of this robot:

This car uses a very working principle that is as follows: ~ When the car reaches the end of the table i.e. the edge of the table the ultrasonic sensor detects its depth of it and it makes the car go back.

If you have not understood its working principle then take a look at the whole tutorial you might then understand it...

So let's get started with the project :-)

Step 1: ​🚀 Materials Required

Image

International:

(Amazon)

• Arduino Uno: https://amzn.to/3zJpqrU

• L298D Motor Driver: https://amzn.to/3vA9dBO

• Bluetooth Module: https://amzn.to/3vA9dBO

• UltraSonic Sensor: https://amzn.to/3vA9dBO

• Gear Motor: https://amzn.to/3vA9dBO

• Rubber Wheel: https://amzn.to/3vA9dBO

• Battery Holder: https://amzn.to/3vA9dBO

• Battery: (Get it in old power bank)

India:

(Quartz Components)

• Arduino Uno: https://bit.ly/3cOLKX2

• L298D Motor Driver: https://bit.ly/3cOLKX2

• Bluetooth Module: https://bit.ly/3cOLKX2

• UltraSonic Sensor: https://bit.ly/3cOLKX2

• Gear Motor: https://bit.ly/3cOLKX2

• Rubber Wheel: https://bit.ly/3cOLKX2

• Battery Holder: https://bit.ly/3cOLKX2

• Battery: https://bit.ly/3cOLKX2

Step 2: Making of the Chassy

Image

~ So for making the chassis I am using cardboard which is cut into the size of 10*14 cm.

~ Then we need a gear motor 4pcs.

~ We will stick the motor with the cardboard using the hot glue gun.

~ We move into the wiring of the motors, the wiring will go in this way, we will solder the wires to the motors "+" and "-" terminals. As shown in the above image.

~ We will require a rubber wheel (4pcs) for the motor.

~ Put the rubber wheel in the gear motors. As shown in the above images.

~ Then our chassis is ready.

let's move into the next step...

Step 3: Attach the Motor Driver With the Arduino Uno & Connecting the Motor Wires With the Motor Driver

Image

~ Now this step is very simple you need to attach the motor driver to Arduino Uno. Just motor driver according to the pin in the Arduino Uno.

~ So here we go, we need to put all the wires of the motor to the motor driver's Motor terminals.

Just put the first motor's wire to the motor driver M1 terminal. Then put the second motor's wire to the M2 terminal. Do the same with the rest of the motors.

Step 4: Mounting the Ultrasonic Sensor & Bluetooth Module Into the Chassis

Image Image Image

~ We will simply take four jumper wires for Ultrasonic Sensor and four jumper wires for Bluetooth Module.

~ Attach it to the Ultrasonic sensor's pins:

+5v, GND, Trigg, Echo.

~ Attach it to the Bluetooth Module's pins:

+5v, GND, Tx, Rx.

~ Then we will fix the Ultrasonic sensor & Bluetooth Module to the Chassis with the help of Double-Sided Tap.

See the Next Step...

Step 5: Connection of Ultrasonic Sensor & Bluetooth Module to Arduino...& Battery Holder

Image

~ Simply Connect the Sensor's:

Trigg to A0 (Arduino)

Echo to A1 (Arduino)

GND to Gnd

VCC to +5V

~ Simply Connect the Bluetooth Module's:

Rx to Tx (Arduino)

Tx to Rx (Arduino)

GND to Gnd

VCC to +5V

Following pin Into the Arduino.

~ We will that a Battery Holder and fix it to the chassis using Double Sided Tap.

Then Connect the GND wire of Holder to the Motor driver's Power GND Terminal . Then Connect the +5V wire to the Vcc or +5V Terminal of Motor driver.

Step 6: Time to Upload the Sketch

Image

~ Now connect the usb cable to the Arduino Uno.

~ remove the Rx pin of the Bluetooth Module for the successful uploading of the code.

Now simply upload the following code:

//Arduino edge Avoidaing Robot
//Created By DIY Burner
//Contact me here https://www.instagram.com/diy_burner/
//You need to include AF Motor.h library before uploading the sketch, otherwise you'll get compilation error message.

#include <AFMotor.h>
const int trigPin = A1 ; //Servo trig pin to D10
const int echoPin = A0; // Servo echo pin to D11

AF_DCMotor motor1(1, MOTOR12_1KHZ); 
AF_DCMotor motor2(2, MOTOR12_1KHZ); 
AF_DCMotor motor3(3, MOTOR34_1KHZ);
AF_DCMotor motor4(4, MOTOR34_1KHZ);

char command; 

void setup() 
{   
  Serial.begin(9600);  //Set the baud rate to your Bluetooth module.
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  
}

long duration;
int distance;

void loop(){
  /*Serial.print("Right");
    Serial.println(Right);
    Serial.print("Left");
    Serial.println(Left);*/

  digitalWrite(trigPin , HIGH);
  delayMicroseconds(1000);
  digitalWrite(trigPin , LOW);

  duration = pulseIn(echoPin , HIGH);
  distance = (duration/2) / 28.5;

  if(Serial.available() > 0){ 

    command = Serial.read(); 
    Stop(); 
    Serial.println(command);
    if(distance <= 0 || distance <= 20)
    {
    switch(command){
    case 'F':  
      forward();
      break;
    case 'B':  
       back();
      break;
    case 'L':  
      left();
      break;
    case 'R':
      right();
      break;
    }
    else
    {
      Stop();
      delay(15);
      back();
      delay(30);
      Stop();
    }
    
 }
}

void forward()
{
  motor1.setSpeed(150); //Define maximum Speed
  motor1.run(FORWARD); //rotate the motor clockwise
  motor2.setSpeed(150); //Define maximum Speed
  motor2.run(FORWARD); //rotate the motor clockwise
  motor3.setSpeed(150);//Define maximum Speed
  motor3.run(FORWARD); //rotate the motor clockwise
  motor4.setSpeed(150);//Define maximum Speed
  motor4.run(FORWARD); //rotate the motor clockwise
}

void back()
{
  motor1.setSpeed(150); //Define maximum Speed
  motor1.run(BACKWARD); //rotate the motor anti-clockwise
  motor2.setSpeed(150); //Define maximum Speed
  motor2.run(BACKWARD); //rotate the motor anti-clockwise
  motor3.setSpeed(150); //Define maximum Speed
  motor3.run(BACKWARD); //rotate the motor anti-clockwise
  motor4.setSpeed(150); //Define maximum Speed
  motor4.run(BACKWARD); //rotate the motor anti-clockwise
}

void left()
{
  motor1.setSpeed(200); //Define maximum Speed
  motor1.run(BACKWARD); //rotate the motor anti-clockwise
  motor2.setSpeed(200); //Define maximum Speed
  motor2.run(BACKWARD); //rotate the motor anti-clockwise
  motor3.setSpeed(200); //Define maximum Speed
  motor3.run(FORWARD);  //rotate the motor clockwise
  motor4.setSpeed(200); //Define maximum Speed
  motor4.run(FORWARD);  //rotate the motor clockwise
}

void right()
{
  motor1.setSpeed(200); //Define maximum Speed
  motor1.run(FORWARD); //rotate the motor clockwise
  motor2.setSpeed(200); //Define maximum Speed
  motor2.run(FORWARD); //rotate the motor clockwise
  motor3.setSpeed(200); //Define maximum Speed
  motor3.run(BACKWARD); //rotate the motor anti-clockwise
  motor4.setSpeed(200); //Define maximum Speed
  motor4.run(BACKWARD); //rotate the motor anti-clockwise
} 

void Stop()
{
  motor1.setSpeed(0); //Define minimum Speed
  motor1.run(RELEASE); //stop the motor when release the button
  motor2.setSpeed(0); //Define minimum Speed
  motor2.run(RELEASE); //rotate the motor clockwise
  motor3.setSpeed(0); //Define minimum Speed
  motor3.run(RELEASE); //stop the motor when release the button
  motor4.setSpeed(0); //Define minimum Speed
  motor4.run(RELEASE); //stop the motor when release the button
}

Step 7: All Set, Now It's Time to Test It

After done with uploading the code. Just put the battery to the Battery Holder and enjoy the project.

Watch our YouTube video to see its testing video .Watch Now!

We're Done Now. I hope you like my project and if you have any queries then leave your comments here, I will surely help you with it or if you have any idea of any new type of project then please comment here I will be definitely making it.

I'll keep updating this article.

For Business or Promotion Query e-mail me on: Email

Thanks for watching project, I hope you liked this project, if you did then please follow me I'll keep posting awesome new projects. Also, don't forget to SUBSCRIBE my YouTube channel. (YouTube: roboattic Lab)

Thank you...Bye...Bye

Related Topics:arduino project

Related Articles

How to Make Gesture Control Robot || #MadeWithArduinoarduino project
May 21, 2022

How to Make Gesture Control Robot || #MadeWithArduino

The transmitter of the car contains gyroscopic sensors which track our hand's gestures and transmit the signal to the receiver of the car and then the car works accordingly to it.

Read More
Build Your Own Object Tracking 4 DOF Robotics Arm With Arduinoarduino project
July 31, 2023

Build Your Own Object Tracking 4 DOF Robotics Arm With Arduino

In this project, the robotic arm will execute actions corresponding to the commands received from the sensors.

Read More
How to Make an Arduino Obstacle Avoiding Car With Mecanum Wheelarduino project
May 22, 2024

How to Make an Arduino Obstacle Avoiding Car With Mecanum Wheel

In this project, we will use an Ultrasonic Sensor to measure distances. Based on the detected distance, the car will take appropriate actions.

Read More