Simple Obstacle-Avoiding Robot
by pramarkimperio in Circuits > Arduino
139 Views, 0 Favorites, 0 Comments
Simple Obstacle-Avoiding Robot

A Simple Obstacle-Avoiding Robot is an autonomous mobile robot designed to navigate an environment without human intervention while avoiding obstacles in its path. It typically uses basic sensors (like ultrasonic, infrared, or bump sensors) to detect objects and make decisions to change direction, ensuring smooth movement.
Supplies
Materials needed:
*Arduino UNO or Nano
*Ultrasonic Sensor
*Motor driver
*Two BO motors, with wheels
*Battery
*Breadboard
Connections and Wirings

- H-C-SR04:
- This refers to the HC-SR04 Ultrasonic Sensor, a popular module used for measuring distance. It works by emitting ultrasonic waves and measuring the time taken for the echo to return, allowing it to calculate distances accurately.
- The sensor typically has four pins: VCC (power), Trig (trigger), Echo (receive), and GND (ground).
- UNO:
- This likely refers to the Arduino Uno, a widely used microcontroller board based on the ATmega328P. It is commonly paired with sensors like the HC-SR04 for projects involving distance measurement, obstacle avoidance, or robotics.
- ARDUZNO:
- This appears to be a misspelled or stylized version of "Arduino," possibly for creative or illustrative purposes.
Interpretation:
The diagram seems to depict a basic setup where an HC-SR04 Ultrasonic Sensor is connected to an Arduino Uno. Such a setup is typical for beginners learning about sensor integration and microcontroller programming. The wiring would involve connecting the sensor's pins to the Arduino's digital and power pins, followed by writing code to read and process distance data.
Coding
int trigPin = 9; // trig pin of HC-SR04
int echoPin = 10; // Echo pin of HC-SR04
int revleft4 = 4; //REVerse motion of Left motor
int fwdleft5 = 5; //ForWarD motion of Left motor
int revright6 = 6; //REVerse motion of Right motor
int fwdright7 = 7; //ForWarD motion of Right motor
long duration, distance;
void setup() {
delay(random(500,2000)); // delay for random time
Serial.begin(9600);
pinMode(revleft4, OUTPUT); // set Motor pins as output
pinMode(fwdleft5, OUTPUT);
pinMode(revright6, OUTPUT);
pinMode(fwdright7, OUTPUT);
pinMode(trigPin, OUTPUT); // set trig pin as output
pinMode(echoPin, INPUT); //set echo pin as input to capture reflected waves
}
void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH); // send waves for 10 us
delayMicroseconds(10);
duration = pulseIn(echoPin, HIGH); // receive reflected waves
distance = duration / 58.2; // convert to distance
delay(10);
// If you dont get proper movements of your robot then alter the pin numbers
if (distance > 19)
{
digitalWrite(fwdright7, HIGH); // move forward
digitalWrite(revright6, LOW);
digitalWrite(fwdleft5, HIGH);
digitalWrite(revleft4, LOW);
}
if (distance < 18)
{
digitalWrite(fwdright7, LOW); //Stop
digitalWrite(revright6, LOW);
digitalWrite(fwdleft5, LOW);
digitalWrite(revleft4, LOW);
delay(500);
digitalWrite(fwdright7, LOW); //movebackword
digitalWrite(revright6, HIGH);
digitalWrite(fwdleft5, LOW);
digitalWrite(revleft4, HIGH);
delay(500);
digitalWrite(fwdright7, LOW); //Stop
digitalWrite(revright6, LOW);
digitalWrite(fwdleft5, LOW);
digitalWrite(revleft4, LOW);
delay(100);
digitalWrite(fwdright7, HIGH);
digitalWrite(revright6, LOW);
digitalWrite(revleft4, LOW);
digitalWrite(fwdleft5, LOW);
delay(500);
}
}
Downloads
Assemble in Tinkercad
https://www.tinkercad.com/dashboard/designs/circuits