Now that we know how to define procedures, let's learn a simple way to use a pushbutton sensor (also known as a touch sensor).
Start off by clicking on the Click for Sensor A box, and select Push Sensor. Now click on the sensor itself. It should push in and turn green while you are clicking on it (indicating true) and spring out and turn red when you release the mouse (indicating false).
|
Run Button ^ |
|
|
Type the procedure on the right into the Procedure window
or
.
Then, type test into the Run This line, click the Download button, and then click on the Cricket's Run Button. |
to test a, on waituntil [switcha] a, off end |
Now, click on the touch sensor. The sensor becomes true, waituntil finishes, and the Cricket executes the a, off command. The motor should turn off!
If you want to try it again, click on the Cricket's Run Button to restart the procedure.