Code not working
Lithium_fun!
Posts: 18
I don't understand why this code won't work. It's for LED candles.
'---[noparse][[/noparse]Pins]
candle1 PIN 0
candle2 PIN 1
candle3 PIN 2
'---[noparse][[/noparse]Variables]
cc1 VAR Bit
cc2 VAR Bit
cc3 VAR Bit
zc1 VAR Word
zc2 VAR Word
zc3 VAR Word
'---[noparse][[/noparse]Main Program]
DO
· RANDOM cc1
· RANDOM cc2
· RANDOM cc3
·' IF (cc1 = 0) THEN
·'·· zc1 = zc1 + 1
·' ELSEIF (cc2 = 0) THEN
·'·· zc2 = zc2 + 1
·' ELSEIF (cc3 = 0) THEN
·'·· zc3 = zc3 + 1
·' ENDIF
· IF (cc1 = 0) THEN
··· LOW candle1
· ELSE
··· HIGH candle1
· ENDIF
· IF (cc2 = 0) THEN
··· LOW candle2
· ELSE
··· HIGH candle2
· ENDIF
· IF (cc3 = 0) THEN
··· LOW candle3
· ELSE
··· HIGH candle3
· ENDIF
LOOP
'---[noparse][[/noparse]Pins]
candle1 PIN 0
candle2 PIN 1
candle3 PIN 2
'---[noparse][[/noparse]Variables]
cc1 VAR Bit
cc2 VAR Bit
cc3 VAR Bit
zc1 VAR Word
zc2 VAR Word
zc3 VAR Word
'---[noparse][[/noparse]Main Program]
DO
· RANDOM cc1
· RANDOM cc2
· RANDOM cc3
·' IF (cc1 = 0) THEN
·'·· zc1 = zc1 + 1
·' ELSEIF (cc2 = 0) THEN
·'·· zc2 = zc2 + 1
·' ELSEIF (cc3 = 0) THEN
·'·· zc3 = zc3 + 1
·' ENDIF
· IF (cc1 = 0) THEN
··· LOW candle1
· ELSE
··· HIGH candle1
· ENDIF
· IF (cc2 = 0) THEN
··· LOW candle2
· ELSE
··· HIGH candle2
· ENDIF
· IF (cc3 = 0) THEN
··· LOW candle3
· ELSE
··· HIGH candle3
· ENDIF
LOOP
bs2
1K
Comments
You will need to add two lines to the beginning of your program similar to these:
' {$STAMP BS2}
' {$PBASIC 2.5}
If the first compiler directive above does not describe the PBASIC Stamp that you are using, then change it accordingly (BS2SX, BS2PE, etc). Complete information on the $STAMP compiler directive can be found in the PBASIC Manual, or the PBASIC Help File.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
m1 VAR Word
cc1 VAR m1.BIT0