Explanation: The following behavior, will make the robot follow the black line, no matter if it is straight or curved. Note that “white” in this case has been defined as all values below 750 – this value needs to be adjusted individually, according to the used sensor and environment.
If the left IR-sensor sees white: run left motor.
Else: stop left motor.
If the right IR-sensor sees white: run right motor.
Else: stop right motor.