Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
I'm looking for a simple reaction timer that I can use with my science classes. I've got QBasic. I've got a program already (below) but it doesn't want to work: I'm guessing that it's something to do with line 210 but I can't figure it out. Any help fixing this one or pointimg me in the direction of another would be very much appreciated. Thanks.
start of program
90 RANDOMIZE 10: REM (Your computer may not need this line.)
120 REM It starts by clearing the screen, and then printing a message:
PRINT "When the screen goes blank, press the SPACEBAR as fast as you can."
PRINT "The Screen will go blank very soon...
REM The next step is to make a random delay:
210 delay=10000 + INT(RND*50000)
220 FOR t = 1 TO delay
230 key$ = INKEY$: IF LEN(key$)>0 THEN PRINT "You jumped the gun!": GOTO 210
240 NEXT t
270 REM The next step is to clear the screen, then use the built in TIMER to
280 REM find the starting time, and then the time when the key is pressed.
310 start = TIMER
320 key$ = INKEY$: IF LEN(key$) = 0 GOTO 320
330 presskey = TIMER
REM Then calculate the difference, rounded to the nearest 100th of a second
REM and then print it
390 diff = (INT((presskey - start) *100)/100)
400 PRINT : PRINT "Your reaction time = "; diff; " seconds"
430 PRINT : PRINT : PRINT : PRINT "Press the SPACEBAR to try again…"
440 key$ = INKEY$: IF LEN(key$) = 0 GOTO 440
450 IF key$ = " " GOTO 140
end of program
0 · ·