A line follower robot that can follow a curvilinear path directed by a line, where both are of different colours. It uses the Proportional, Integral & Derivative functions to calculate the error and tries to minimize that error so as to improve the movement of the robot.
Resources
Components Used
- Arduino Nano
- QTR-8A Reflectance Sensor Array
- L293D Motor Driver/ TB6612FNG Driver
- 2 x N20-6V-300 Rpm Micro Metal Gear Motor
- 2 x Pololu Wheel 42x19mm
- 7.4V Lipo Battery
P, I, and D are represented by the three terms that add together here. Kp, Ki, and Kd are constants that tune how the system reacts to each factor.
int error = position - 3500;
int motorSpeed = Kp * error + Kd * (error - lastError);
lastError = error;
int rightMotorSpeed = BaseSpeed + motorSpeed;
int leftMotorSpeed = BaseSpeed - motorSpeed;
The maximum speed has been set to 225, the base speed is 155 and the turning speed is set to 100. All of which can be changed to 255(max. speed) if needed.