Users Manual
CLASS 3
116
Let's take a closer look at the script for the LED sensor behavior in the 'StartUp' script we learned earlier. At the end
of the 'StartUp' script, there is a big script to see how the LED sensor works. The role of this script is to keep the
LED sensor on continuously when the door is open and to blink the LED sensor every 1 second if the door is closed.
Make a script like the one above.
First, the 'infinite loop' block means that we will continue to check the script in this block indefinitely. Inside the
'infinite loop' block, there is a 'if' block, which executes the scripts contained inside when certain conditions
are met, ie, the value stored in the 'door' variable = close, then activate the internal script. If the 'door = close'
condition is met (if the door is closed), turn on Digital 10 output (turn on LED). Wait for 1 second with the LED
on, then turn off Digital 10 output (turn off the LED). And wait another second. This will cause the LED sensor to
flash at 1 second intervals when the door is closed. However, if you do not satisfy the 'door = close' condition, ie
if the door is open, keep the Digital 10 output on. (The LED is still on).
So, we learned about the operation of the LED sensor. On the next page we will try to code the script
when we receive the 'Open_door' broadcast (when the door is open).
Tori Secret Safe LED Coding
Activity