Rahul Humanfollowingrobot
Rahul Humanfollowingrobot
Aim:
Develop a human following bot using Arduino uno
INTRODUCTION
COMPONENTS REQUIRED
SOFTWARE REQUIRED
Arduino IDE
CIRCUIT DIAGRAM
2
Three ultrasonic sensors are incorporated into this design, enabling
readings of distance in the front, right, and left directions. Through the
corresponding digital pins on the Arduino board, these sensors are
connected. Two DC motors are also included in the circuit for
movement, and they are linked to an L298N motor driver module. Using
the appropriate digital pins on the Arduino board, the motor driver
module is then attached to the board. Two 3.7V li-ion cells are used to
power the complete setup, and they are connected to the motor driver
module using a switch.
CIRCUIT CONNECTIONS
3
Connect the ENA and ENB pins of the motor driver module to the
on -board High state pin with the help of female header.
Connect the OUT1, OUT2, OUT3, and OUT4 pins of the motor
driver module to the appropriate terminals of the motors.
Connect the VCC (+5V) and GND pins of the motor driver module
to the appropriate power (Vin) and ground (GND) connections on
the Arduino.
Connect the negative terminal of the power supply to the GND pin
of the motor driver module.
Connect the GND pin of the Arduino to the GND pin of the motor
driver module.
ARDUINO CODE
#define S1Trig 2
#define S2Trig 4
#define S3Trig 6
#define S1Echo 3
#define S2Echo 5
#define S3Echo 7
#define LEFT_MOTOR_PIN1 8
#define LEFT_MOTOR_PIN2 9
4
#define RIGHT_MOTOR_PIN1 10
#define RIGHT_MOTOR_PIN2 11
#define MAX_DISTANCE 40
#define MIN_DISTANCE_BACK 5
#define MIN_SPEED 75
Void setup() {
pinMode(LEFT_MOTOR_PIN1, OUTPUT);
pinMode(LEFT_MOTOR_PIN2, OUTPUT);
pinMode(RIGHT_MOTOR_PIN1, OUTPUT);
pinMode(RIGHT_MOTOR_PIN2, OUTPUT);
pinMode(S2Trig, OUTPUT);
pinMode(S3Trig, OUTPUT);
pinMode(S1Echo, INPUT);
pinMode(S2Echo, INPUT);
5
pinMode(S3Echo, INPUT);
Serial.begin(9600);
Void loop() {
Serial.print(“Front: “);
Serial.print(frontDistance);
Serial.print(leftDistance);
Serial.print(rightDistance);
Serial.println(“ cm”);
moveBackward();
Serial.println(“backward”);
6
} else if (frontDistance < leftDistance && frontDistance < rightDistance &&
frontDistance
< MAX_DISTANCE) {
moveForward();
Serial.println(“forward”);
turnLeft();
Serial.println(“left”);
turnRight();
Serial.println(“right”);
} else {
Stop();
Serial.println(“stop”);
Int sensorOne() {
7
//pulse output
digitalWrite(S1Trig, LOW);
delayMicroseconds(2);
digitalWrite(S1Trig, HIGH);
delayMicroseconds(10);
digitalWrite(S1Trig, LOW);
Int sensorTwo() {
//pulse output
digitalWrite(S2Trig, LOW);
delayMicroseconds(2);
digitalWrite(S2Trig, HIGH);
delayMicroseconds(10);
digitalWrite(S2Trig, LOW);
8
int cm = t / 29 / 2; //Convert time to the distance
Int sensorThree() {
//pulse output
digitalWrite(S3Trig, LOW);
delayMicroseconds(2);
digitalWrite(S3Trig, HIGH);
delayMicroseconds(10);
digitalWrite(S3Trig, LOW);
Void moveForward() {
analogWrite(LEFT_MOTOR_PIN1, MAX_SPEED);
9
analogWrite(LEFT_MOTOR_PIN2, LOW);
analogWrite(RIGHT_MOTOR_PIN1, MAX_SPEED);
analogWrite(RIGHT_MOTOR_PIN2, LOW);
Void moveBackward() {
analogWrite(LEFT_MOTOR_PIN1, LOW);
analogWrite(LEFT_MOTOR_PIN2, MAX_SPEED);
analogWrite(RIGHT_MOTOR_PIN1, LOW);
analogWrite(RIGHT_MOTOR_PIN2, MAX_SPEED);
Void turnRight() {
analogWrite(LEFT_MOTOR_PIN1, LOW);
analogWrite(LEFT_MOTOR_PIN2, MAX_SPEED);
analogWrite(RIGHT_MOTOR_PIN1, MAX_SPEED);
analogWrite(RIGHT_MOTOR_PIN2, LOW);
Void turnLeft() {
analogWrite(LEFT_MOTOR_PIN1, MAX_SPEED);
analogWrite(LEFT_MOTOR_PIN2, LOW);
10
analogWrite(RIGHT_MOTOR_PIN1, LOW);
analogWrite(RIGHT_MOTOR_PIN2, MAX_SPEED);
Void stop() {
analogWrite(LEFT_MOTOR_PIN1, LOW);
analogWrite(LEFT_MOTOR_PIN2, LOW);
analogWrite(RIGHT_MOTOR_PIN1, LOW);
analogWrite(RIGHT_MOTOR_PIN2, LOW)}
CONCLUSION
11
QUESTIONS
12
a. By detecting changes in infrared radiation
b. By measuring temperature variations
c. By emitting and receiving ultrasonic waves to determine
distance to objects
d. By detecting light intensity
13
8. What is the main advantage of using Arduino for building a
human-following robot?
a. Low processing power
b. Limited sensor compatibility
c. Ease of programming and prototyping
d. High cost of components
14
15