geezer88
Senior Member
I'm playing with a Picaxe 18M2. I've got eight leds connected to the port B pins. They are arranged with current limiting resistors to 5+, then to the output, so when the output is low, the light comes on. There are no other connections to the 18M2 except needed for power and programming. The program below works as expected, but I'm not sure why:
The manual says on a 18M2 that individual pins should be addressed as B.3 or whatever, but when I tried to make a variable in place of the 3, the compiler gives a syntax error. So, I tried the simple high 3 and that does work. How does the compiler know that it is port B that I'm referring to? I am quite confused by the individual pin outputting inspite of reading the manual several times.
thanks,
tom
Code:
symbol cntr = b0
main:
outpinsb = 255 ;raise all outputs to turn off leds
lupe:
for cntr = 0 to 7
low cntr ;drop output to turn on single led
pause 50
high cntr
next cntr
for cntr = 7 to 0 step -1 ;do it all backwards
low cntr
pause 50
high cntr
next cntr
goto lupe ;repeat cycle
end
thanks,
tom