To make a robot move on a line using a light sensor.
Final Program
Figure : Case 0 corresponds to the case where the sensor "sees" white.
Figure : Case 1 here is the other case corresponding to the light sensor reading an intensity less than threshold (i.e) light sensor "sees" black.
Creating a Ring Constant
The constants White and Black in the program are not numeric constants but Ring Constants which are similar to dropdown menus. These constants let you choose between one of many options. To enter the White and Black options, create a ring constant and right click on the constant and select Edit Items on the dropdown. In the Edit Items window, Insert two constants White and Black in that order.
Figure : Selecting the Ring Constant from the Functions palette
Figure : Creating two items within the Ring Constant in the Edit Items menu.
Once this is done, draw the Case Structure within the While loop, and put the blocks within the case structure box as shown above. Wire all the blocks, in particular use a single connection from the "White" ring constant placed outside the While loop to the ? symbol on the Case Structure through the While loop. Notice that the "tunnels" on the while loop look as solid blocks and not as the small triangles shown above. The small triangles on the while loop are the Shift Registers. To do this change, right click on the tunnel and choose Replace with Shift Registers.
Figure : Replacing the blue tunnel box to Shift Register. Once you choose the Replace with Shift Register option, you will see that the cursor changes to a box with a triangle and click the other blue box on the other side of the while loop to change both tunnels to Shift Registers.
Two cases of the Case Structure
You will notice that there are two arrows on the top of the case structure to switch between the cases. To make the two different cases, make the case 1 first and then copy the contents, switch the case to case 0, using the arrows on top of the case structure, and paste the blocks. Change the Steering constant to -30 and make sure the blocks are wired as in the other case.