Anthony Roggenbuck

Home Up Feedback Contents

 

Home
Up
Resume
Transcript
Projects
Work Experience
Recreation

 

 

 

 

 

 

 

 

Reaction Time Code

' {$STAMP BS2}
' {$PBASIC 2.5}
' {$PORT COM5}

timeCounter VAR Word
value VAR Byte

Value = 23

DEBUG "Press and hold pushbutton.", CR,
"to make light turn red.", CR, CR,
"When light turns green, let", CR,
"go as fast as you can.", CR, CR

DO

    DO
    LOOP UNTIL IN3 = 1

    LOW 14
    HIGH 15

    RANDOM value
    DEBUG "Delay time ", ? 1000 +value, CR

    PAUSE 1000 + value

    HIGH 14
    LOW 15

    timecounter = 0

DO



    PAUSE 1
    timecounter = timecounter +1

    LOOP UNTIL IN3 = 0

    LOW 14

IF (timecounter = 1) THEN
    DEBUG "WAIT UNTIL LIGHT TURNS RED", CR

    ELSE

    DEBUG "Your time was ", DEC timeCounter,
    "ms.", CR, CR,
    "To play again, hold the ", CR,
    "button down again.", CR,CR
ENDIF
LOOP

 

Send mail to with questions or comments about this web site to anthony@roggenbuck.us
Copyright 2007 Anthony Roggenbuck