We'll add the light sensor to the robot in class, and have the sensor face toward the ground.
The light sensor gives a reading from 0 to 100.
You can have the robot do different things depending on the current reading of the light sensor.
You can test the reading by selecting View on the robot then clicking on it until the arrow points at the location where you put your sensor (probably 2). Try putting the light sensor over different colored surfaces and see how the reading changes.
The light sensor is often used with the "repeat until" statement or the yes-no statement (if statement)
Problems
1. Build a program that causes the robot to drive along the black strip on the lego test pad. When the robot gets to the end of the black strip, it should stop.
2. Build a program that has the robot drive back and forth on the black strip.
A variable is a little piece of memory you can use to record things. In the Mindstorm programming system, variables hold numbers and are often used to count things.
Set a variable-- use this to initialize the value of a variable.
Add -- modify a variable.
Yes-No blocks are the way you perform 'conditional' statements with Mindstorms. The Yes-No block is equivalent to the 'if' statement in textual programming languages,
Problem
Build a program that counts the number of green lines on the test pad.