0% found this document useful (0 votes)
47 views

Rahul Humanfollowingrobot

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views

Rahul Humanfollowingrobot

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

G7.

9 :HUMAN FOLLOWING ROBOT


Learning outcome : Understanding the working of ultrasonic sensors and l298N motor driver. Developing
basic idea of coding

Aim:
Develop a human following bot using Arduino uno

INTRODUCTION

A human-following robot represents an innovative and technologically


advanced application in the field of robotics. Designed to autonomously
track and follow human movements, this intelligent robot utilizes a
combination of sensors, cameras, and sophisticated algorithms to
identify and pursue a person in its vicinity. The concept of a human-
following robot is rooted in the pursuit of enhancing human-robot
interaction, providing a hands-free, intuitive, and personalized robotic
companion. Whether employed for assistance in various industries,
navigation in public spaces, or as a companion in smart homes, these
robots showcase the seamless integration of artificial intelligence and
robotics.

COMPONENTS REQUIRED

 Arduino UNO board ×1


 Ultrasonic sensor ×3
 L298N motor driver ×1
 Robot chassis
 BO motors ×2
 Wheels ×2
 Li-ion battery
 Battery holder ×1
 Breadboard
 Ultrasonic sensor holder ×3
 Switch and jumper wires

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

 Connect the VCC pin of each ultrasonic sensor to the 5V pin on


the Arduino board.
 Connect the GND pin of each ultrasonic sensor to the GND pin on
the Arduino board.
 Connect the trigger pin (TRIG) of each ultrasonic sensor to
separate digital pins (2,4, and 6) on the Arduino board.
 Connect the echo pin (ECHO) of each ultrasonic to separate digital
pins (3,5, and 7) on the Arduino board.
 Connect the digital output pins of the Arduino (digital pins 8, 9, 10,
and 11) to the appropriate input pins (IN1, IN2, IN3, and IN4) on
the motor driver module.

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 MAX_SPEED 150

#define MIN_SPEED 75

Void setup() {

// Set motor control pins as outputs

pinMode(LEFT_MOTOR_PIN1, OUTPUT);

pinMode(LEFT_MOTOR_PIN2, OUTPUT);

pinMode(RIGHT_MOTOR_PIN1, OUTPUT);

pinMode(RIGHT_MOTOR_PIN2, OUTPUT);

//Set the Trig pins as output pins


pinMode(S1Trig, OUTPUT);

pinMode(S2Trig, OUTPUT);

pinMode(S3Trig, OUTPUT);

//Set the Echo pins as input pins

pinMode(S1Echo, INPUT);

pinMode(S2Echo, INPUT);

5
pinMode(S3Echo, INPUT);

// Initialize the serial communication for debugging

Serial.begin(9600);

Void loop() {

Int frontDistance = sensorOne();

Int leftDistance = sensorTwo();

Int rightDistance = sensorThree();

Serial.print(“Front: “);

Serial.print(frontDistance);

Serial.print(“ cm, Left: “);

Serial.print(leftDistance);

Serial.print(“ cm, Right: “);

Serial.print(rightDistance);

Serial.println(“ cm”);

// Find the sensor with the smallest distance

If (frontDistance < MIN_DISTANCE_BACK) {

moveBackward();

Serial.println(“backward”);

6
} else if (frontDistance < leftDistance && frontDistance < rightDistance &&
frontDistance

< MAX_DISTANCE) {

moveForward();

Serial.println(“forward”);

}else if (leftDistance < rightDistance && leftDistance < MAX_DISTANCE) {

turnLeft();

Serial.println(“left”);

} else if (rightDistance < MAX_DISTANCE) {

turnRight();

Serial.println(“right”);

} else {

Stop();

Serial.println(“stop”);

Delay(100); // Delay for stability and to avoid excessive readings

// Function to measure the distance using an ultrasonic sensor

Int sensorOne() {

7
//pulse output

digitalWrite(S1Trig, LOW);

delayMicroseconds(2);

digitalWrite(S1Trig, HIGH);

delayMicroseconds(10);

digitalWrite(S1Trig, LOW);

long t = pulseIn(S1Echo, HIGH);//Get the pulse

int cm = t / 29 / 2; //Convert time to the distance

return cm; // Return the values from the sensor


}

//Get the sensor values

Int sensorTwo() {

//pulse output

digitalWrite(S2Trig, LOW);

delayMicroseconds(2);

digitalWrite(S2Trig, HIGH);

delayMicroseconds(10);

digitalWrite(S2Trig, LOW);

long t = pulseIn(S2Echo, HIGH);//Get the pulse

8
int cm = t / 29 / 2; //Convert time to the distance

return cm; // Return the values from the sensor

//Get the sensor values

Int sensorThree() {

//pulse output

digitalWrite(S3Trig, LOW);

delayMicroseconds(2);

digitalWrite(S3Trig, HIGH);

delayMicroseconds(10);

digitalWrite(S3Trig, LOW);

long t = pulseIn(S3Echo, HIGH);//Get the pulse

int cm = t / 29 / 2; //Convert time to the distance

return cm; // Return the values from the sensor

// Motor control functions

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

Using an Arduino board and three ultrasonic sensors, we created a


human-following robot that integrates electronics, programming,
and mechanics.Human-following robots can be employed in a
variety of settings, such as retail establishments, shopping centers,
and lodging facilities, to offer guests individualized service.Robots
that follow humans can be used in surveillance and security
systems to track and keep an eye on people in public areas.They
can be applied to research and development, education and
research, guided tours, entertainment and events, senior care, and
personal robotics.

11
QUESTIONS

1. What is the primary function of a human-following robot


using Arduino?
a. Detecting obstacles
b. Following predefined paths
c. Tracking and following human movements
d. Conducting environmental sensing

2. Which sensor is commonly used in human-following robots to


detect the presence of humans?
a. Ultrasonic sensor
b. Infrared sensor
c. Temperature sensor
d. Light sensor

3. In a human-following robot system, what is the role of the


Arduino microcontroller?
a. Powering the motors
b. Processing sensor data and controlling actuators
c. Providing wireless communication
d. Monitoring battery voltage

4. How does an ultrasonic sensor contribute to the functionality


of a human-following robot?

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

5. What type of motor control mechanism is commonly used in


human-following robots?
a. Analog control
b. PWM (Pulse Width Modulation) control
c. Digital control
d. Servo control

6. Which Arduino function is typically used to read sensor data


in a human-following robot?
a. digitalRead()
b. analogRead()
c. digitalWrite()
d. analogWrite()

7. How does a human-following robot differentiate between a


human and other objects?
a. By measuring the object’s weight
b. By analyzing the object’s shape and movement patterns
c. By detecting the object’s temperature
d. By emitting a specific sound signal

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

9. Which factor is essential for ensuring accurate and reliable


operation of a human-following robot?
a. The color of the robot’s chassis
b. The weight of the ultrasonic sensor
c. The precision of sensor measurements
d. The length of the motor driver cables

10. In a human-following robot, what action should the robot


take if the ultrasonic sensor detects a human within a certain
range?

a. Increase its speed


b. Stop moving
c. Change direction randomly
d. Slow down and maintain a constant distance

14
15

You might also like