I was playing around in NXT-G today and found an interesting fact with the LOOP block.
I set up a loop to play a high note, 1 second break, low note, 1 second break and to loop until touch sensor is pressed. Once the touch sensor is 'pressed' it will break out of the loop and say goodbye.
Now if I press and release the touch sensor when it is playing the low note, by time it has finished the high note, the touch sensor is no longer pressed and the program loops as expected. To paraphrase, because the touch sensor has not been pressed at the exact time the loop block is checked, it continues to loop. This is exactly I as expected.
However, if I change the the loop condition to look for the sensor being 'bumped' (pressed and released) it doesn't matter when in the loop I press the button, it will remember it and once it checks the loop conditions after the high note, it will exit the loop.
This also works for the NXT buttons as inputs but not any of the other sensors.
--
Damien Kee
I set up a loop to play a high note, 1 second break, low note, 1 second break and to loop until touch sensor is pressed. Once the touch sensor is 'pressed' it will break out of the loop and say goodbye.
Now if I press and release the touch sensor when it is playing the low note, by time it has finished the high note, the touch sensor is no longer pressed and the program loops as expected. To paraphrase, because the touch sensor has not been pressed at the exact time the loop block is checked, it continues to loop. This is exactly I as expected.
However, if I change the the loop condition to look for the sensor being 'bumped' (pressed and released) it doesn't matter when in the loop I press the button, it will remember it and once it checks the loop conditions after the high note, it will exit the loop.
This also works for the NXT buttons as inputs but not any of the other sensors.
--
Damien Kee