Addressing all PINS at once for LED Sequencer?

Andrei IRL

Senior Member
Hi everyone.
This is probably a very basic question, but howcan i address all pins at once on a PICAXE18 (X i think, 10 year old chip).

I am making a Christmas jumper with 3D printed Christmas trees on it with 9 LEDS each.

I am creating a program that would run them in a couple pf different sequences but its very daunting to be typing HIGH and LOW for each LED.

This is the code i have so far.

Any help to make it an easier process is highly appreciated.

Code:
symbol led9=c.1
symbol led8=c.0
symbol led7=c.7
symbol led6=c.6
symbol led5=b.7
symbol led4=b.6
symbol led3=b.5
symbol led2=b.4
symbol led1=b.3
main:
let b0=5

do b0=b0-1
	toggle led9
	pause b0
	toggle led8
	pause b0
	toggle led7
	pause b0
	toggle led6
	pause b0
	toggle led5
	pause b0
	toggle led4
	pause b0
	toggle led3
	pause b0
	toggle led2
	pause b0
	toggle led1	
	pause b0
loop while b0>0
	low led9
	pause 200
	low led8
	pause 200
	low led7
	pause 200
	low led6
	pause 200
	low led5
	pause 200
	low led4
	pause 200
	low led3
	pause 200
	low led2
	pause 1000
	low led1
 

hippy

Technical Support
Staff member
On the 18X you can use either "pins=" or "outpinsB=".

You cannot however use port C for output.
 

mezzrow

Member
Out of home, not in condition to help better.

Hi everyone.
This is probably a very basic question, but howcan i address all pins at once on a PICAXE18 (X i think, 10 year old chip).

I am making a Christmas jumper with 3D printed Christmas trees on it with 9 LEDS each.

I am creating a program that would run them in a couple pf different sequences but its very daunting to be typing HIGH and LOW for each LED.

This is the code i have so far.

Any help to make it an easier process is highly appreciated.

Code:
symbol led9=c.1
symbol led8=c.0
symbol led7=c.7
symbol led6=c.6
symbol led5=b.7
symbol led4=b.6
symbol led3=b.5
symbol led2=b.4
symbol led1=b.3
main:
let b0=5

do b0=b0-1
	toggle led9
	pause b0
	toggle led8
	pause b0
	toggle led7
	pause b0
	toggle led6
	pause b0
	toggle led5
	pause b0
	toggle led4
	pause b0
	toggle led3
	pause b0
	toggle led2
	pause b0
	toggle led1	
	pause b0
loop while b0>0
	low led9
	pause 200
	low led8
	pause 200
	low led7
	pause 200
	low led6
	pause 200
	low led5
	pause 200
	low led4
	pause 200
	low led3
	pause 200
	low led2
Have a look at manual 2:
LET pins / pinsA / pinsB / pinsC / pinsD = value
Set/clear all outputs on the main output port (let pins = ), or on a specific port (let pinsA/pinsB/pinsC/pinsD =).
High and low commands can be used to switch individual outputs high and low.
 
Last edited by a moderator:

jims

Senior Member
Andrei...if you could possibly work with 8 LEDs...this simple routine works nicely. JimS
Code:
[color=Navy]#picaxe [/color][color=Black]18m2[/color]

[color=Blue]pause [/color][color=Navy]1000[/color]
[color=Blue]let [/color][color=Purple]dirsB [/color][color=DarkCyan]= [/color][color=Navy]%11111111 [/color][color=Green]; 7,0,1 as outputs[/color]
[color=Black]Main:
    [/color][color=Blue]do
    let [/color][color=Purple]w1[/color][color=DarkCyan]=[/color][color=Navy]%10000000
    [/color][color=Blue]do
     let [/color][color=Purple]pinsB [/color][color=DarkCyan]= [/color][color=Purple]w1
     [/color][color=Blue]Let [/color][color=Purple]w1 [/color][color=DarkCyan]= [/color][color=Purple]w1 [/color][color=DarkCyan]/ [/color][color=Navy]2 [/color][color=Green]
     [/color][color=Blue]pause [/color][color=Navy]1000 [/color][color=Green]'rate to change LED's ON/OFF.
    [/color][color=Blue]loop until [/color][color=Purple]w1 [/color][color=DarkCyan]= [/color][color=Navy]0
    [/color][color=Blue]loop[/color]
 
Last edited:

Andrei IRL

Senior Member
Super. I was actually thinking about reducing number of LEDs to 7 so i can control the lot using CAT5 cable.

Thanks very much for the code.

I will try using it in my program.
 

hippy

Technical Support
Staff member
If you wire the LED's up as a matrix you can control 16 LEDs with just 8 wires.

More if you wanted to get into charlie-plexing though that isn't so easy with older fixed output devices like the 18X.

The easy option is to simply go to 7 LEDs.
 
Top