CS 372: Artificial Intelligence
Robot Building Lab
Session 4

Resource Kit
Outfitting A Robot Laboratory
Sample Syllabus for an AI Course
Robot Laboratory Handout
Session 3
Session 5



Light Sensors

Today you will be handed two light sensors. The sensors are simple Cadmium Sulfide photoresistors. The resistance of the sensors changes when the amount of light it receives changes. Thus, when connected into the analog input ports of the Handy Board (ports 0 through 6), the change in resistance can be converted using the built-in analog to digital converters. Thus the values on these ports will vary between 0 and 255. The exact values you will receive from your light sensors will vary in that range. You will get lower values (close to zero) for bright light, and higher values (typically close to 255) for dark conditions. Thus, before you use the light sensor, you will have to calibrate them to get an idea of the sensitivity of your sensors.

The sensors themselves have been mounted on LEGO pieces so that you can easily make them a part of the assembly of your robot. You can use these light sensors to model several different behaviors: hiding in the dark, staying in the light, following a flashlight.

Today's lab exercise is to learn the use of light sensors by interfacing them to your Handy Board. Also, you can start calibrating them.

Plug the handy board into the computer. Plug in the light sensors in the analog ports (ports numbered 0 through 6). The IC command:


analog(PORTNUMBER);


returns a number between 0 and 255 depending on the inputs to the port numbered PORTNUMBER. Issue the command several times, varying the amount of light incident on the sensor (your flashlight should come in handy here) to determine the response of the sensors.

You may find that it is important to calibrate your sensors relative to ambient light. The degree of variation used by your programs can be relative to ambient light rather than absolute values. Since ambient light varies from room to room, or even in the same room with different lighting conditions, it may be a good idea to make your robot adapt itself to any particular ambient light. This can easily be done by sensing ambient light at the beginning of its operation. For instance, you may explicitly request the user to push the START button before the behavior is actually modeled. Then, prior to PUSHING the button, your program can sense the ambient light. This is called self calibration or acclimatization. Of course, since the START button and the power ON switch are quite close to each other, and depending on your assembly the light sensors may also be close by, make sure that your hands are away from the sensors while doing the initial sensing!


Exercise

You can extend the behavior of your robot from last week's lab by adding a light source to serve as a beacon for the exit. I.e., if, the exit to the corral were brighter than the rest of the area. Design an algorithm to make use of this new information so that your robot can find the exit more efficiently.


Other Possible Behaviors

Think of some other behaviors that could now be accomplished by using the light sensors. Can you use it so that it detects the edge of a table, in order to avoid a fall? Can you use these sensors to model line following behavior?

In the next lab session, you will be expected to demonstrate the corral exiting behavior. You should have two versions, one that uses only the touch sensors, and one that uses both types of sensors.



Resource Kit
Outfitting A Robot Laboratory
Sample Syllabus for an AI Course
Robot Laboratory Handout
Session 3
Session 5 ÿ