0

Soccer Robot C - Basic lessons - Stop on line

The robot detects dark and bright surface using a line sensor. Arduino program can read one of its 9 (or less) transistors, and one of the robot's 4 line sensors, using command line(transistorNumber, sensorNumber). The result will be true (if the surface is white) or false (if it is not). For example,
if (line(0, 2))
	print("Bright");
else
	print("Dark");
can be used to determine the surface under left reflectance sensor. If the surface is white, the first line (if...) will return "true" and that means that the command following "if" will be executed. That command will print "Bright". On the other hand, when the surface is not bright, the "if..." will return "false" and that means that the command following "else" will be executed, printing "Dark". Try this program. The whole code is here:
void RobotSoccer::loop() {
	if (line(0, 2))
		print("Bright");
	else
		print("Dark");
}

Task: stop on line

Write a program that will be moving the robot straight ahead till it hits a white surface below transistor 0 of the left sensor.