. Arduino Human Following Robot Project ~ SmartElectronicsDIY

Arduino Human Following Robot Project

 

The Human Following Robot uses ultrasonic sensors to detect a person and automatically follows them while maintaining a safe distance. The robot moves forward, left, right, or stops based on human position.


🔧 Components Required

  • Arduino UNO

  • Ultrasonic Sensor HC-SR04 (1 or 2 sensors)

  • Motor Driver L298N

  • DC Motors × 2

  • Robot Chassis + Wheels

  • 12V Battery / Power Bank

  • Jumper Wires

  • Breadboard

(Optional: IR sensors for better accuracy)


⚙️ Working Principle

  1. Ultrasonic sensor emits ultrasonic waves.

  2. Waves reflect from the human body.

  3. Arduino calculates distance.

  4. Based on distance:

    • Too far → Move Forward

    • Too close → Stop

    • Left detected → Turn Left

    • Right detected → Turn Right


📐 Distance Formula

Distance (cm) = (Time × 0.034) / 2

🔌 Circuit Connections

HC-SR04 → Arduino

HC-SR04Arduino
VCC5V
TrigD9
EchoD10
GNDGND

L298N Motor Driver → Arduino

L298N PinArduino
IN1D2
IN2D3
IN3D4
IN4D5
ENA5V
ENB5V
GNDGND

💻 Arduino Code

#define trigPin 9 #define echoPin 10 #define IN1 2 #define IN2 3 #define IN3 4 #define IN4 5 long duration; int distance; void setup() { pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT); pinMode(IN3, OUTPUT); pinMode(IN4, OUTPUT); Serial.begin(9600); } void loop() { digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); distance = duration * 0.034 / 2; Serial.println(distance); if (distance > 20 && distance < 60) { moveForward(); } else if (distance <= 20) { stopRobot(); } else { stopRobot(); } } void moveForward() { digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW); digitalWrite(IN3, HIGH); digitalWrite(IN4, LOW); } void stopRobot() { digitalWrite(IN1, LOW); digitalWrite(IN2, LOW); digitalWrite(IN3, LOW); digitalWrite(IN4, LOW); }

📊 Output Behavior

DistanceRobot Action
> 60 cmStop
20–60 cmFollow Human
< 20 cmStop

🚀 Applications

  • Assistant robots

  • Service robots

  • Surveillance robots

  • Smart shopping carts

  • Robotics learning projects

0 comments:

Post a Comment