When it comes to programming I’m not the best. I need help with a simple idea.
I can easily program the three color LEDs on the ABB (Pins 4-6) to turn on, pause for 50ms then turn off and each lead is turned on, then off one after the other to give a sorta light chasing effect. I want to write as few lines of code as possible to achive the same results which is where I need help. For one, How do you make the pin a variable that can be cycled between p4-p6?
; NOTE: "LOW" is ON and "HIGH" is OFF. It is backwards for these LEDs
top:
low p4
pause 50
high p4
lowp5
pause
high p5
low p6
pause 50
high p6
low p6
pause 50
high p6
low p5
pause 50
high p5
low p4
pause 50
high p4
goto top
I haven’t used basic in some time (and didn’t use it much to begin with), so I’m not sure if this is going to compile (I think this might work on an Atom, but possibly not a Parallax stamp).
[code]
blinkdir VAR sbyte
led VAR nib
led=4
blinkdir=1
top:
LOW led
PAUSE 50
HIGH led
led = led + blinkdir
IF led = 6 or led = 4 THEN
blinkdir = blinkdir * -1
ENDIF
GOTO top[/code]
You mean you do not need the “P” then the number? I thought Mbasic used P4 for pin 4, and I was thinking how do I split the P and the number and have it work.