westaust55
Moderator
I have be using a series of IF...THEN type statements to control a group of LED's as a bar graph but then seem to recall seeing a recent thread asking if there was a better way. (cannot find that thread now!)
Had a look this evening and in the interests of sharing code snippets here is my contribution that should work on all PICAXE's.
Changing the No of LED's is a relatively easy task in terms of the calcs. Just need to use a word variable for pattern and amend the output subroutine.
My LED group is driven via an i2c bus 8-bit IO expander but changing the pattn2led subroutine will easily accomodate those using 74HC595 shift registers.
and if you have an X1 or X2 type PICAXE it is even easier with:
Had a look this evening and in the interests of sharing code snippets here is my contribution that should work on all PICAXE's.
Changing the No of LED's is a relatively easy task in terms of the calcs. Just need to use a word variable for pattern and amend the output subroutine.
My LED group is driven via an i2c bus 8-bit IO expander but changing the pattn2led subroutine will easily accomodate those using 74HC595 shift registers.
Code:
; -----[ Program Code ]----------------------------------------------------
;
; [B][COLOR="Red"]DELETED HERE - SEE POST No 4 BELOW FOR BETTER CODE[/COLOR][/B]
;===========================================
and if you have an X1 or X2 type PICAXE it is even easier with:
Code:
; -----[ Program Code ]----------------------------------------------------
;
; [B][COLOR="Red"]DELETED HERE - SEE POST No 4 BELOW FOR BETTER CODE[/COLOR][/B]
;===========================================
Last edited: