Pure Software code
 
www.puresoftwarecode.com

SOFTWARE Institute
Teach YourSelf
125 Software Programming Training Courses
For Free Download


CHRISTIANITY Institute
HUMANITIES Institute
Art Institute

All more the 500 Subjects, All for Free Download.
Lebanon  
Robot Car 4WD with Arduino, Obstacle Avoiding.
 
 
  Home :  Chapter 5: 4WD Robot Car, Obstacle Avoiding                                                                                                                              Home
 
The Chapters :      1  2   3   4   5   6 
 

Chapter 5: 4WD Robot Car, Obstacle Avoiding.

 
 
 
  1- Obstacles Avoidance robot and Follower robot , Project description
 
An obstacle avoiding robot is a fully autonomous robot which can be able to avoid any obstacle which it face when it move.

Simply, when it met an obstacle while it moving forward, automatically stop moving forward and makes a step back.

Then it looks it's two sides left & right and starts to move the best possible way; which means either in left direction if there is another obstacle in right or in right direction if there is another obstacle in left side.

Obstacle avoiding robots actually avoid obstacles using sensors like ultrasonic where they calculate by transmission and receiving of radiations. These kinds of technology can be used in automated automobiles or trains where when they find something big in their way they would stop preventing damage. Obstacle follower on the contrary follows the obstacle.
 
 2- Components Used in Obstacles Robot
 
  Types Qty
2.1 Arduino Uno R3 1pcs
2.2 V5.0 Expansion board 1pcs
2.3 L293D motor driver board 1pcs
2.4 BO motor 4pcs
2.5 Servo motor 1pcs
2.6 Ultrasonic Sensor 1pcs
2.7 Wheel 4pcs
2.8 Battery Case + Lithium-ion battery 1pcs + 2pcs
2.9 Acrylic plates 2pcs
2.10 USB cable 1pcs
2.11 Servo motor fixed plate + Ultrasonic holder 1pcs + 1pcs
2.12 Aluminium Block 4pcs
2.13 F-F dupont wire  
 
 3- Obstacles Avoidance robot and Follower robot, Servo Motor and Ultrasonic
 
 

 

3.1   Steering gear is a Servo motor that moves the ultrasonic sensor from left to right
3.2   Ultrasonic distance sensor, which consists of a transmitter and receiver. The sensor measures how far things are without touching them, and it uses sound waves to get the measurements right. It can work well when things are between two to four centimeters away.
 
 
  4- Video, Obstacles Avoidance and Follower Of the Multi-Functional 4 Wheel Drive Robot Car
  4.1- Watch Video on Youtube, Arduino Smart Car, Obstacles Avoidance Robot  - Part 4   السيارة الذكية - روبوت تجاوز وتتبع الحواجز، الدرس 32 - الجزء 4 - للمهندس حمزة عمار
   Video on Youtube, Arduino Smart Car, Obstacles Avoidance Robot and Follower Robot  - Part 4 https://www.youtube.com/watch?v=SW0VhwAhKPY&t=0s
 
  5- Project 1,  Obstacles Avoidance robot  -  Code, use the Mixly block programming  
 
  5.1-  the Description  of the Current Application

 
   5.2- the Code  of the Current Application (Line Following), Using the Mixly Software Current Mixly application - (3.76 KB zip file)   download
 
    5.2.1- Picture, the Mixly Blocks(block programming) of the Current Application

 
    5.2.2- Picture,  the Mixly Code of the Current Application, Equivalent to C++

 
    5.2.3- the Code  of the Current Application
#include <Servo.h>

volatile int IN1;
volatile int IN2;
volatile int IN3;
volatile int IN4;
volatile int rightDistance;
volatile int leftDistance;
Servo servo_4;

void left_side_forward(int speed) {
// Left
analogWrite(IN1,(speed * 0.90));
analogWrite(IN2,0);
}

void right_side_forward(int speed) {
// Right
analogWrite(IN3,speed);
analogWrite(IN4,0);
}

void left_side_backword(int speed) {
// Left
analogWrite(IN1,0);
analogWrite(IN2,(speed * 0.90));
}

void right_side_backward(int speed) {
// Right
analogWrite(IN3,0);
analogWrite(IN4,speed);
}

float checkdistance_A1_A2() {
digitalWrite(A1, LOW);
delayMicroseconds(2);
digitalWrite(A1, HIGH);
delayMicroseconds(10);
digitalWrite(A1, LOW);
float distance = pulseIn(A2, HIGH) / 58.00;
delay(10);
return distance;
}

void forward(int speed) {
left_side_forward(speed);
right_side_forward(speed);
}

void backword(int speed) {
left_side_backward(speed);
right_side_backward(speed);
}

void left(int speed, int time) {
left_side_backward(speed);
right_side_forward(speed);
delay(time);
stop();
}

void right(int speed, int time) {
left_side_forward(speed);
right_side_backward(speed);
delay(time);
stop();
}

void stop() {
left_side_forward(0);
right_side_forward(0);
}

void setup(){
IN1 = 11;
IN2 = 6;
IN3 = 5;
IN4 = 3;
rightDistance = 3;
leftDistance = 3;
servo_4.attach(4);
pinMode(A1, OUTPUT);
pinMode(A2, INPUT);
}

void loop(){
servo_4.write(90);
delay(500);
while (checkdistance_A1_A2() > 15) {
forward(100);
}
stop();
servo_4.write(0);
delay(500);
rightDistance = checkdistance_A1_A2();
servo_4.write(180);
delay(500);
leftDistance = checkdistance_A1_A2();
if (rightDistance >= leftDistance) {
right(200, 380);

} else {
left(200, 380);

}

}
 
    5.2.4- Test the Current Application
     1- Connect the Arduino UNO board of the 4WD robot car to computer’s USB port with USB cable to upload the code
     2- if the Code upload success, Turn the Power Slide switch ON
 
 
  6- Project 2,  Obstacles  Follower Robot  -  Code, use the Mixly block programming  
 
  6.1-  the Description  of the Current Application

 
   6.2- the Code  of the Current Application (Line Following), Using the Mixly Software Current Mixly application - (2.96 KB zip file)   download
 
    6.2.1- Picture, the Mixly Blocks(block programming) of the Current Application

 
    6.2.2- Picture,  the Mixly Code of the Current Application, Equivalent to C++

 
    6.2.3- the Code  of the Current Application
volatile int IN1;
volatile int IN2;
volatile int IN3;
volatile int IN4;
volatile int distance;

void backword(int speed) {
left_side_backward(speed);
right_side_backward(speed);
}

float checkdistance_A1_A2() {
digitalWrite(A1, LOW);
delayMicroseconds(2);
digitalWrite(A1, HIGH);
delayMicroseconds(10);
digitalWrite(A1, LOW);
float distance = pulseIn(A2, HIGH) / 58.00;
delay(10);
return distance;
}

void forward(int speed) {
left_side_forward(speed);
right_side_forward(speed);
}

void left_side_backward(int speed) {
// Left
analogWrite(IN1,0);
analogWrite(IN2,(speed * 0.90));
}

void left_side_forward(int speed) {
// Left
analogWrite(IN1,(speed * 0.90));
analogWrite(IN2,0);
}


void right_side_backward(int speed) {
// Right
analogWrite(IN3,0);
analogWrite(IN4,speed);
}

void right_side_forward(int speed) {
// Right
analogWrite(IN3,speed);
analogWrite(IN4,0);
}


void stop() {
left_side_forward(0);
right_side_forward(0);
}

void setup(){
IN1 = 11;
IN2 = 6;
IN3 = 5;
IN4 = 3;
distance = 0;
pinMode(A1, OUTPUT);
pinMode(A2, INPUT);
}

 

void loop(){
distance = checkdistance_A1_A2();
if (distance >= 15 && distance <= 20) {
stop();
} else if (distance > 20) {
 forward(120);

} else if (distance < 15 ) {
backword(120);

}

}

 
    6.2.4- Test the Current Application
     1- Connect the Arduino UNO board of the 4WD robot car to computer’s USB port with USB cable to upload the code
     2- if the Code upload success, Turn the Power Slide switch ON
 
 
 
The Chapters :     -   1  2   3   4   5   6 
 
 www.puresoftwarecode.com  :  CHRISTIANITY Institute  HUMANITIES Institute  ART Institute & Others
 SOFTWARE Institute - "All Courses Free"    History of the MARONITES in Arabic  Basilica Architecture, in the Shape of a Cross

 Python, Teach yourSelf  Programs in 6 pages

 Holy BIBLE in 22 Languages and Studies ...  Le HANDICAP c'est quoi ?   (in French)  
 VISUAL STUDIO 2019, C# Programs, in English  220 Holy Christian ICONS  Drugs and Treatment in English, french, Arabic  Old Traditional Lebanese houses
 VISUAL STUDIO 2010 in English  Catholic Syrian MARONITE Church   Classification of Wastes from the Source in Arabic  5 DRAWING Courses & 3 Galleries
 VISUAL STUDIO .NET, Windows & ASP in En  HOLY MASS of  Maronite Church - Audio in Arabic  Christianity in the Arabian Peninsula in Arabic  Meteora, Christianity Monasteries - En, Ar, Fr
 VISUAL STUDIO 6.0 in English  VIRGIN MARY, Mother of JESUS CHRIST GOD  Summary of the Lebanese history in Arabic  Monasteries of Mount Athos & Pilgrimage
 Microsoft ACCESS in English  SAINTS of the Church  LEBANON EVENTS 1840 & 1860, in Arabic  Carved Rock Churches, Lalibela - Ethiopia
 PHP & MySQL in English  Saint SHARBEL - Sharbelogy in 10 languages, Books  Great FAMINE in LEBANON 1916,  in Arabic   4 Different STUDIES
 SOFTWARE GAMES in English  Catholic RADIO in Arabic, Sawt el Rab  Great FAMINE and Germny Role 1916,  in Arabic   SOLAR Energy & Gas Studies
 WEB DESIGN in English  Saint SHARBEL Family - Evangelization  Armenian Genocide 1915  in Arabic  Personal Protective Equipment
 JAVA SCRIPT in English  Читать - БИБЛИЯ и Шарбэль cвятой, in Russe  Sayfo or Assyrian Genocide 1915 in Arabic  WELCOME to LEBANON
 FLASH - ANIMATION in English  Apparitions of  Virgin Mary - Ar  Christianity in Turkey in Arabic  YAHCHOUCH, my Lebanese Village
 PLAY, 5 GAMES  Neocatechumenal Way   Prononce English and French and Arabic Letters  ZOUEIN, my Family - History & Trees
 Multi-Functional 4 Wheel Drive Robot Car              New  Holy BIBLE, for the Maronite Liturgical Year  Andree Zouein Foundation  
 HERMEZ Steel, Steel  Decor Artwork  Holy BIBLE, according to Maronite Calendar, (2023)  GIGI  L'AMOROSO Fashion and Jewellery   my PRODUCTS, and Statistiques ...
 SAADEH BEJJANE Architecture  Holy BIBLE, Online Translation in 133 Languages  Josette Zoueïn. Psychanalyste Psychologue  REPORT, Cyber Attack Attacks the Current Site
CARLOS SLIM HELU Site.  new design      
       Chucri Simon Zouein, Computer engineer
     
echkzouein@gmail.com
© pure software code - Since 2003