Photocell circuit, need help!
TheForsythe
Posts: 12
So far ive got this:
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Elevator Capacity Check!", CR
LightCount VAR Byte
DO
LightCount = 0 ' Initialize counter to 0
DO : LOOP UNTIL IN13 = 1 'Wait for elevator door to close
Counter:
PAUSE 2000 'Pause for 2 seconds while people get settled
IF IN0 = 0 THEN LightCount = LightCount + 1 ' PhotoCell on, count it
IF IN1 = 0 THEN LightCount = LightCount + 1 ' PhotoCell on, count it
IF IN2 = 0 THEN LightCount = LightCount + 1 ' PhotoCell on, count it
IF IN3 = 0 THEN LightCount = LightCount + 1 ' PhotoCell on, count it
IF IN4 = 0 THEN LightCount = LightCount + 1 ' PhotoCell on, count it
IF IN5 = 0 THEN LightCount = LightCount + 1 ' PhotoCell on, count it
IF IN6 = 0 THEN LightCount = LightCount + 1 ' PhotoCell on, count it
IF IN7 = 0 THEN LightCount = LightCount + 1 ' PhotoCell on, count it
IF IN8 = 0 THEN LightCount = LightCount + 1 ' PhotoCell on, count it
IF IN9 = 0 THEN LightCount = LightCount + 1 ' PhotoCell on, count it
IF IN10 = 0 THEN LightCount = LightCount + 1 ' PhotoCell on, count it
IF IN11 = 0 THEN LightCount = LightCount + 1 ' PhotoCell on, count it
IF IN12 = 0 THEN LightCount = LightCount + 1 ' PhotoCell on, count it
DEBUG DEC LightCount, CR ' Output number of photocells that are not seeing light
IF LightCount > 9 THEN OUT15 = 1 ELSE OUT15 = 0 ' Turn on LED when 10 or more photocells see light
Hold:
DO : LOOP UNTIL IN13 = 1
OUT15 = 0
DO : LOOP WHILE IN13 = 1
DEBUG ? IN13
PAUSE 250
LOOP
I need to have the counter wait until IN13 = 1 and then start counting. This is right at the beginning of my program, here:
LightCount = 0 ' Initialize counter to 0
DO : LOOP UNTIL IN13 = 1 'Wait for elevator door to close
Counter:
PAUSE 2000 'Pause for 2 seconds while people get settled
how do i do this?!?!?!
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Elevator Capacity Check!", CR
LightCount VAR Byte
DO
LightCount = 0 ' Initialize counter to 0
DO : LOOP UNTIL IN13 = 1 'Wait for elevator door to close
Counter:
PAUSE 2000 'Pause for 2 seconds while people get settled
IF IN0 = 0 THEN LightCount = LightCount + 1 ' PhotoCell on, count it
IF IN1 = 0 THEN LightCount = LightCount + 1 ' PhotoCell on, count it
IF IN2 = 0 THEN LightCount = LightCount + 1 ' PhotoCell on, count it
IF IN3 = 0 THEN LightCount = LightCount + 1 ' PhotoCell on, count it
IF IN4 = 0 THEN LightCount = LightCount + 1 ' PhotoCell on, count it
IF IN5 = 0 THEN LightCount = LightCount + 1 ' PhotoCell on, count it
IF IN6 = 0 THEN LightCount = LightCount + 1 ' PhotoCell on, count it
IF IN7 = 0 THEN LightCount = LightCount + 1 ' PhotoCell on, count it
IF IN8 = 0 THEN LightCount = LightCount + 1 ' PhotoCell on, count it
IF IN9 = 0 THEN LightCount = LightCount + 1 ' PhotoCell on, count it
IF IN10 = 0 THEN LightCount = LightCount + 1 ' PhotoCell on, count it
IF IN11 = 0 THEN LightCount = LightCount + 1 ' PhotoCell on, count it
IF IN12 = 0 THEN LightCount = LightCount + 1 ' PhotoCell on, count it
DEBUG DEC LightCount, CR ' Output number of photocells that are not seeing light
IF LightCount > 9 THEN OUT15 = 1 ELSE OUT15 = 0 ' Turn on LED when 10 or more photocells see light
Hold:
DO : LOOP UNTIL IN13 = 1
OUT15 = 0
DO : LOOP WHILE IN13 = 1
DEBUG ? IN13
PAUSE 250
LOOP
I need to have the counter wait until IN13 = 1 and then start counting. This is right at the beginning of my program, here:
LightCount = 0 ' Initialize counter to 0
DO : LOOP UNTIL IN13 = 1 'Wait for elevator door to close
Counter:
PAUSE 2000 'Pause for 2 seconds while people get settled
how do i do this?!?!?!
Comments
Maybe you need to first describe carefully what you're trying to do, step by step. Usually it's better to describe what you want to do rather than start writing code, then work from that description (once it looks correct) when you start to write code. Remember that a description describes your intent ... what you want to accomplish in terms of your original problem, not a prose version of code.