I present to you the advance of the robot following lines that I have worked lately.
Components:
1 Arduino Nano
1 Arduino Nano Shield 5 CNY70 sensors
2 IR Sensors GP1A01 (Similar FC-03)
1 Driver L298N
2 Motors with gearbox and encoder
2 Batteries 3.7V 4200mAH 18650
1 18650 battery holder
1 5V USB charger
1 1P1T switch
1 Pushbutton
1 2-tier circular acrylic chassis
2 Wheels covered with eva foam
2 Sphere wheels
2 double-sided perforated breadboard
Some LEDs and SMD resistors and various connecting cables







This is one of the first functional tests, in which I included the use of the programming of the PID feedback algorithm in which at the moment I use the constants P and D.




Adjustments regarding speed control through RPM and activate the constant I are pending.




The sensors used five CNY70 and are read analogically. Initially it is necessary to calibrate the sensors for best performance (10 seconds).
CNY70 Datasheet: https://pdf1.alldatasheet.com/datasheet-pdf/view/252297/VISHAY/CNY70.html





The motors are powered by 2x3.7V 4200mAH 18650 batteries in series (7.4V) and for the control part (Arduino Nano) I use a 5V USB portable charger.





I include the physical design made in TinkerCAD








I have made some templates with which depending on the way they are placed, any size of track can be made. I have done 2, but the limit is imatination.






This is a special bonus, where I show the simulation of this same robot on Webot. The code used to control it virtually is based on the Arduino code used in the real robot. In the description of the video you can find access to information regarding the Webots platform, documentation and corresponding code. I hope you like it.
🛠️ เจาะลึกเบื้องหลังการทำงาน (Deep Dive / Technical Analysis)
The Human Following Robot is a fascinating project that demonstrates basic computer vision principles using simple infrared (IR) sensors. It mimics the behavior of a faithful pet, following its "owner" autonomously as long as they stay within sensing range.
![images/projects/expanded/images/projects/expanded/human_following_robot_front_1772704505968.png)
The Sensing Principle
This robot relies on an array of sharp-edged infrared sensors. These sensors emit a beam and detect reflections from objects in front of them.
- Left Movement: If only the left sensor detects a reflection, the robot turns its motors to pivot left.
- Right Movement: If only the right sensor detects a reflection, it turns right.
- Forward: If the center sensor (or all sensors) detects an object at a certain distance, it moves forward to follow it.
- Safety Stop: The code ensures the robot stops before it actually hits the person it's following.
Hardware Components
- Arduino Uno/Nano: Processes the sensor array and translates it into motor movements.
- IR Obstacle Sensors (x3): Mounted on the front in a staggered pattern (Left, Center, Right).
- L298N Motor Driver Shield: Controls the high-power DC gear motors.
- Robot Chassis: 2-wheel or 4-wheel base with a caster for easy turning.
- Li-ion/Li-po Battery: High-capacity power source to handle both motors and the Arduino.
![images/projects/expanded/images/projects/expanded/ir_sensor_array_detail_1772704523332.png)
Coding the Logic
The heart of the code is a series of if/else statements that compare the current sensor readings. We use conditional logic to decide between moving, turning, or stopping. Smoothing the motor speed using PWM (Pulse Width Modulation) prevents the robot from being too jerky, making the following behavior look much more natural and fluid.