Single-digit counter
TMB
Posts: 2
Hi,
I'm new to pbasic, and I'm trying to make a single-digit counter which counts as long as you hold a button pressed, and then stops counting and displays the number the count is at when you release the button.
This is what I got so far:
But whenever i release the button, it stops at the number 9 no matter what :S
Can someone help?
I'm new to pbasic, and I'm trying to make a single-digit counter which counts as long as you hold a button pressed, and then stops counting and displays the number the count is at when you release the button.
This is what I got so far:
' {$STAMP BS2} ' {$PBASIC 2.5} Segs VAR OUTL SegsDirs VAR DIRL Button VAR IN8 idx VAR Nib Digit0 DATA %00111111 Digit1 DATA %00000110 Digit2 DATA %01011011 Digit3 DATA %01001111 Digit4 DATA %01100110 Digit5 DATA %01101101 Digit6 DATA %01111101 Digit7 DATA %00000111 Digit8 DATA %01111111 Digit9 DATA %01100111 Reset: SegsDirs = %01111111 Main: IF Button = 1 THEN FOR idx = 0 TO 9 READ (Digit0 + idx), Segs PAUSE 25 NEXT ENDIF GOTO Main
But whenever i release the button, it stops at the number 9 no matter what :S
Can someone help?
Comments
You need to put a command that checks the button status within the "for next" loop.