Comp 2673, Spring 2003

Lab 8

May 20 and 22, 2003

Lego Robot programming :


In this lab you will program your robot to distinguish between various colors (based on their reflectivity) and to follow a line.

Part 1 :


1. Attach the light sensor to your robot (one of the inputs of the RCX brick).
2. Set your RCX brick display so that it shows the value detected by the light sensor. Note, for this you may have to write a program that uses the SetSensor command to inform the brick that a light sensor is attached to the corresponding input.
3. Now move the robot (or the light sensor) over the different colored tapes.  Make a note of the sensor value for each color. Move the sheet with the colored tapes closer to the sensor and further away from it and make note of the sensor values in each case. If possible also find out the values when you take readings closer and further away from a light source (for eg. a window or a different part of the room which has more or less light).

Part 2 :


Write a program that has 3 tasks. The task "main" starts the other 2 tasks. The second task moves the robot forward.
The third task does the following.
To test your program, tape a white sheet of paper to the carpet and let the robot detect the paper and follow the edge of the paper.
You might want to try making different shapes out of paper and see if the robot is able to follow them.