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 wanted

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:
140 CLS
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.
300 CLS
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





Comments

  • : 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:
    : 140 CLS
    : 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.
    : 300 CLS
    : 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
    :
    :
    :
    :

    Yo! Graham!

    I copy/pasted your program into my qbasic env and it ran fine on my p-133. If you have a fairly new computer, I sugggest you try increasing the values in line 210:

    210 delay=100000 + INT(RND*500000)

    good luck!

    rg


  • Try to change line 90 like this:

    90 RANDOMIZE TIMER

    That works


  • : Try to change line 90 like this:
    :
    : 90 RANDOMIZE TIMER
    :
    : That works
    :

    Doesn't appear to make any difference, sorry. Still doesn't work. I've seemingly got quite a few people trying to solve this problem mostly now on alt.basic etc newsgroups. I'm eternally grateful for all their efforts. When I eventually solve I'll post 'definitive version' on this message board. Any other ideas or alternatives are welcome. Thanks, Graham.



Sign In or Register to comment.