Day 3 - Section 3 - Respond to light
Day 3 - Section 3 - Respond to light
After the completion of this section the students will be able to:
- create a Light alarm with their robots
- turn the lights of the robot ON and OFF according to the amount of surrounding light
- program their robot to follow the light
Chapter 8.1 - Light alarm
Click the ‘Add Variable’ button in the top left corner and a pop up box will appear.
Type in the name of your variable as ‘Light_Level’, select the variable range as +/-32767 (word) and set the initial value to zero. Now click OK and your variable will be added to the variables table in the bottom right corner.
The sense light icon reads the light level from the left light sensor and places the reading into the variable called Light_Level.
The first loop uses mathematics to determine what to do.
Loop until the value in the variable called ‘Light_Level’ is ‘greater than’ (>) 100.
When the value in Light_Level is greater than 100 the loop is exited and goes to the next loop that sounds the alarm.
Place the Edison robot in the dark and press the play button. When the lights are turned on, the robot raises the alarm.