An obstacle avoid robot using Arduino is a small autonomous robot that is designed to navigate through a space while avoiding obstacles. The robot is built using an Arduino microcontroller board and various sensors that allow it to detect obstacles in its path.
The robot typically uses ultrasonic or infrared sensors to detect obstacles and determine their distance from the robot. When an obstacle is detected, the robot uses the sensor data to calculate the best path to avoid the obstacle and change its direction of movement.
The Arduino microcontroller board is programmed using the Arduino IDE and is responsible for controlling the movement of the robot. It uses a motor driver circuit to control the speed and direction of the robot's motors, which enables it to move forward, backward, and turn in different directions.
An obstacle avoid robot is a fun and challenging project that requires basic knowledge of electronics and programming. It is an excellent way to learn about robotics and how to integrate different components to build a functional system. The robot can be used for various applications, such as home automation, surveillance, and entertainment.
Arduino Code:
const int trigPin= 11;
const int echoPin= 10;
const int Out1 = 9;
const int Out2 = 8;
const int Out3 = 4;
const int Out4 = 3;
void setup() {
// put your setup code here, to run once:
pinMode (trigPin,OUTPUT);
pinMode(echoPin,INPUT);
pinMode (Out1,OUTPUT);
pinMode(Out2,OUTPUT);
pinMode (Out3,OUTPUT);
pinMode(Out4,OUTPUT);
}
long duration,distance;
void loop() {
// put your main code here, to run repeatedly:
digitalWrite (trigPin,LOW);
delay(2);
digitalWrite (trigPin,HIGH);
delay(10);
digitalWrite (trigPin,LOW);
duration = pulseIn(echoPin,HIGH);
distance = duration/58.2 ;
if (distance<50)
{
digitalWrite(Out1,LOW);
digitalWrite(Out2,HIGH);
digitalWrite(Out3,HIGH);
digitalWrite(Out4,LOW);
}
else
{
digitalWrite(Out1,LOW);
digitalWrite(Out2,HIGH);
digitalWrite(Out3,LOW);
digitalWrite(Out4,HIGH);
}
delay(50);
}
Comments
Post a Comment