This is a line following robot car using Adafruit motor shield and 4 line detecting sensors. Motor speed ranges between 0 to 255 rpm.
Sensors are set in the following format in the front of the car: rightBackgroundDetector | rightMiddleLineDetector | leftMiddleLineDetector | leftBackgroundDetector
This code will assume you are starting on a white background with black line; then moving into black background with white line; and when it reach to the end with all white strip it will stop.
You can set the following variables:
TURN_SPEED 97 //Turning speed of motor
THRESHOLD 500 //Threshold to detect the line sensor, greater than 500 means it detected black line.
bg_right A5 //Port for right background detector