2011_Activity #5 - Reaction timer test

2011_Activity #5 - Reaction timer test - .. LOOP UNTIL IN3...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
'What's a Microcontroller - ReactionTimer.bs2 'Test reaction time with a pushbutton and a bi-colour LED. ' '{$STAMP BS2} '{$PBASIC 2.5} ' timeCounter VAR Word 'Declare Varible to store time. t DEBUG "Press and hold pushbutton", CR, 'Display reaction instructions "to make light turn red.", CR, CR, "When light turns green, let", CR, "go as fast as you can.", CR, CR DO 'Begin main loop D DO 'Nested loop repeats.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: .. LOOP UNTIL IN3 = 1 'Until pushbutton is pressed. LOW 14 'Bi-colour LED red HIGH 15 PAUSE 1000 'Delay 1 second HIGH 14 'Bi-colour LED Green. LOW 15 timeCounter = 0 'Set timeCounter to zero DO PAUSE 1 timeCounter = timeCounter + 1 LOOP UNTIL IN3 = 0 LOW 14 DEBUG "Your time was ", DEC timeCounter, " ms.", CR, CR, "To play again, hold the", CR, "button down again.", CR, CR LOOP...
View Full Document

Ask a homework question - tutors are online