Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

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.

reaction timer - final version

as promised, a version that works perfectly....


90 RANDOMIZE 10: REM (Your computer may not need this line.)
140 CLS
145 PRINT "Program tests reaction time."
150 PRINT "Press any key as soon as the screen goes blank."
155 PRINT "press >ENTER< to begin."
156 INPUT PRESSENTER: PRINT
160 PRINT "The Screen will go blank very soon..."
200 REM makes a random delay:
210 delay = 50000 + INT(RND * 900000): '50000 < delay <=900000
220 FOR t = 1 TO delay
240 NEXT t
270 REM The next step is to clear the screen, then use built-in TIMER command
280 REM to find the starting time, and then the time when the key is pressed.
300 CLS
301 key$ = INKEY$: IF LEN(key$) = 0 THEN 310: 'if no key pressed continue
302 PRINT "Don't press any key prior to blank screen."
303 PRINT "Press >ENTER< to continue...": INPUT PRESSENTER
304 GOTO 140
310 start = TIMER
320 key$ = INKEY$: IF LEN(key$) = 0 GOTO 320: REM loop until key press
330 presskey = TIMER
340 REM calculate the difference, rounded to the nearest 100th of a second
350 REM and print it
390 diff = (INT((presskey - start) * 100) / 100)
400 PRINT : PRINT "Your reaction time = "; diff; " seconds"
430 PRINT : PRINT : PRINT "Press the >SPACEBAR< to try again,"
431 PRINT "Any other key to end."
440 key$ = INKEY$: IF LEN(key$) = 0 GOTO 440
450 IF key$ = " " THEN 140 ELSE END




Sign In or Register to comment.