I also show the class the four modified robots for this project. The ultrasonic sensor (top) and light sensor (front) are now fitted and connected to ports 1 and 4 respectively as shown below:
The next step is to demonstrate the use of these sensors. In the first example I review iteration, or how to create a loop, to flash the lamp. In the second I show how use selection to detect an obstacle with the ultrasonic sensor and in the third how to use selection to sense a change in the amount of reflected light to the light sensor.
1) Move straight forward until it is 50cm from an obstacle, then turn 90 degrees and stop.
2) Navigate around the room while avoiding obstacles using its ultrasonic sensors.
3) Move straight forward until its light sensor detects >50% reflected light, then stop.
4) Navigate around the room while avoiding obstacles and flashing its lamp. When arriving at the "victim", make a sound and stop.