Phototransmitter Counter
XiaWarriors
Posts: 4
in BASIC Stamp
I'm trying to write a pBasic code to Count stuff using a Phototransmitter.
The problem is, it's not working the way I want it to.
I'm trying to make it so even if the Light continues to shine on the phototransmitter (1), it doesn't keep counting. How do I fix this?
The problem is, it's not working the way I want it to.
' {$STAMP BS2}
' {$PBASIC 2.5}
' Only works if Bright Light touches it
' Phototransister
' 0 = Ambient Fluorescent Light
' 1 = Bright Light
Counter VAR Word
Total VAR Word
Total = 0
DO
PAUSE 1000
DEBUG CLS
Counter = IN5
IF Counter = 1 THEN Total = Total + 1
DEBUG ? Counter
DEBUG ? Total
LOOP
I'm trying to make it so even if the Light continues to shine on the phototransmitter (1), it doesn't keep counting. How do I fix this?
Comments
Yea, I thought so, but..
How do I do that?
How is the code suppose to be written?
DO
PAUSE 1000
DEBUG CLS
Counter = IN5
IF Counter = 1 THEN Total = Total + 1
DEBUG ? Counter
DEBUG ? Total
' add these three lines
DO
Counter = IN5
LOOP UNTIL (Counter = 0)
LOOP
I didn't realize you can add another Do/Loop inside another Do/Loop