Shop OBEX P1 Docs P2 Docs Learn Events
program "results" of reacton timer on serial lcd — Parallax Forums

program "results" of reacton timer on serial lcd

Let's Go!Let's Go! Posts: 124
edited 2008-06-25 07:43 in BASIC Stamp
the reaction timer results are given in ms on the 2 button reaction timer, as in pg 99 of parallax manual. does anyone know how to·display the·results·on the lcd(instead of relying on the computer monitor). below is my code for the reaction timer. thanks, jim·:: and below this code i have entered some lcd code that may be approriate. thanks for the efforts...hop.gif
' {$STAMP BS2}
' {$PBASIC 2.5}
'PIN 3 PLAYER A
'Pin 4 player b
timeCountera···· VAR···· Word· 'player a timescore
timeCounterb· VAR·· Word······ 'player b timescore

DEBUG···· "PRESS BOTH BUTTONS FOR RED LIGHT, AND WAIT FOR GREEN LIGHT.",·· CR,CR,CR
DEBUG········· "WHEN LIGHT TURNS GREEN, RELEASE BUTTON",· CR,
········· "AS FAST AS YOU CAN.", CR, CR
DO········································ 'begin main LOOP
·· DO······································ 'nested loop repeats
·· 'nothing
·· LOOP UNTIL (IN3 = 1) AND (IN4 = 1)········ 'until pushbutton release
·· LOW 14·································· 'bi color led red
·· HIGH 15

·· PAUSE 1000······························· 'delay 1 second
·· HIGH 14·································· 'bi color led green
·· LOW 15
·· timeCountera = 0·························· 'set time counter to 0
·· timecounterb = 0
···· DO······································· 'nested loop count time

······ PAUSE 1
······· IF (IN3 = 1) THEN·············· 'if button is still down
······· timecountera = timecountera + 1·· 'increment counter
···· ENDIF
···· IF (IN4 = 1) THEN
···· timecounterb = timecounterb + 1
···· ENDIF
···· LOOP UNTIL (IN3 = 0) AND (IN4 = 0)· 'until both pushbuttons is released
···· LOW 14··································· 'bi color led off
···· DEBUG· "PATTY'S TIME:"· ,·· DEC timeCountera,· " MS.",CR··· 'display time
···· DEBUG· "JIM'S TIME: ", DEC timecounterb, " MS. ", CR, CR
···· IF (timecountera < timecounterb) THEN
···· DEBUG "WINNER IS PATTY!", CR
···· ELSEIF (timecounterb < timecountera) THEN
···· DEBUG "WINNER IS JIM!", CR
···· ELSE············ 'a and b times are equal
···· DEBUG "YOU 2 KNUCKLEHEADS TIED!", CR
···· ENDIF
···· DEBUG CR
···· DEBUG "TO PLAY AGAIN, TELL JIM HE'S COOL! ", CR,CR,CR,CR

LOOP··········································· 'back to begin main loop



' {$STAMP BS2}
' {$PBASIC 2.5}
'lcd scott ed trial BS2 modified TO work.bs2

i·· CON·· 254
clrlcd·· CON· 1
prn_at·· CON· 136
j·· VAR·· Word
n96n·· CON·· $4054
LOW 0
PAUSE 1000
SEROUT 0,n96n,[noparse][[/noparse]i,clrlcd]
SEROUT 0, n96n, [noparse][[/noparse]"number:"]
FOR j = 0 TO 2000
SEROUT 0,n96n,[noparse][[/noparse]i, prn_at,DEC j, "··· "]
PAUSE 30
NEXT
STOP
·

Comments

  • beazleybubbeazleybub Posts: 102
    edited 2008-06-25 07:43
    Are you using a parallel or serial LCD?

    If you are using a parallax serial LCD replace your DEBUG commands where you want to display text on a serial LCD with something similar to this as an example.

    REPLACE THIS:
    DEBUG "YOU 2 KNUCKLEHEADS TIED!", CR

    WITH THIS:
    SEROUT
    13, 84, [noparse][[/noparse]"YOU 2",13 "KNUCKLEHEADS"]
    SEROUT 13, 84, [noparse][[/noparse]12]: PAUSE 500

    SEROUT·13, 84,·[noparse][[/noparse]"TIED!"]

    "Connect your parallax serial LCD'S RX line to pin 13"


    Go have a look here you will find lots of useful information.

    http://www.parallax.com/dl/docs/prod/audiovis/SICSerialLcd.pdf



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    What if there was nothing? Nothing is something!

    Post Edited (beazleybub) : 7/2/2008 7:24:23 AM GMT
Sign In or Register to comment.