counter and switch programming help
i'm doing a mini scoreboard project and im trying to write the code for a counter that is controlled by a "flingy" switch (sorry don't know correct term).· I just simply want the counter to count up one number when i fling the switch up (I position), and count down one number when i fling the switch down (O position).· i dont want the counter to count unless the switch tells it to.· If anyone can help me i would greatly appreciate it.·

Comments
' {$STAMP BS2} ' {$PBASIC 2.5} CntUp PIN 0 CntDn PIN 1 CntMax CON 100 CntMin CON 0 Yes CON 1 No CON 0 SwDelay CON 500 counter VAR Word Main: DO IF (CntUp = Yes) THEN IF (counter < CntMax) THEN counter = counter + 1 GOSUB Update_Display PAUSE SwDelay ENDIF ENDIF IF (CntDn = Yes) THEN IF (counter > CntMin) THEN counter = counter - 1 GOSUB Update_Display PAUSE SwDelay ENDIF ENDIF LOOP END Update_Display: ' your code here... RETURNA schematic is attached.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
Post Edited (Jon Williams) : 2/3/2005 6:51:03 PM GMT