Hey Guys, welcome to my Instructables 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 :-)
(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 an 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
~ 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:
~ 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.
~ We will 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 a Double-Sided Tap.See the Next Step...
Trigg to A0 (Arduino)
Echo to A1 (Arduino)
GND to GND
VCC to +5V
~ Simply Connect the Bluetooth Modules: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 a Double-Sided Tap.
Then Connect the GND wire of the Holder to the Motor driver's Power GND Terminal. Then Connect the +5V wire to the Vcc or +5V Terminal of the motor driver.
~ 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 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
}
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!
Step 8: We're Done 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 definitely make it.
I'll keep updating this article.
For Business or Promotion Query e-mail me on Email
Thanks for watching the 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 to my YouTube channel. (YouTube: DIY BURNER)
Thank you...Bye...Bye
Comments