Electronics Learner 123
Well-known member
Hi all,
I am currently trying to drive the APA102 using the Picaxe 20x2.
I have read the following threads:
https://picaxeforum.co.uk/threads/apa102-rgb-led-strip-examples.30680/
https://picaxeforum.co.uk/threads/apa102-5050-rgb-led-with-integrated-driver.27509/
https://picaxeforum.co.uk/threads/controling-addressable-leds.29327/#post-302643
And I have used code that has been adjusted to work with the 20x2:
Which was kindly provided by TechElder,
However this doesn't seem to work on my apa102 as it gets the lights to light up but with no significant correlation to the code,
I would like to start off my simply controlling specific leds and updating them when I need to. (NOTE: I am using a 60led/m strip).
What I would like to achieve:
Variable ---> is variable 3?
---> is variable 2
---------------------------------------↑ I know how to do the above ↑------------------------------
I am currently trying to drive the APA102 using the Picaxe 20x2.
I have read the following threads:
https://picaxeforum.co.uk/threads/apa102-rgb-led-strip-examples.30680/
https://picaxeforum.co.uk/threads/apa102-5050-rgb-led-with-integrated-driver.27509/
https://picaxeforum.co.uk/threads/controling-addressable-leds.29327/#post-302643
And I have used code that has been adjusted to work with the 20x2:
Code:
#picaxe 20x2
#no_table
#no_data
; =======================================================
; Example 7
; Set all LED modules on
; =======================================================
; 40X2 5V -.- Light strip
; .-----__-----. |
; | RST B.7 | `--> RED +V
; = = .--> SCK --------> BLU CK
; | C.2 C.5 |--|--> SDO --------> GRN DI
; .--| C.3 C.4 | | .--> YEL 0V
; | | D.0 D.3 | | |
; | | D.1 D.2 | | 0V _|_
; | `------------' |
; `------------------'
; Set how many LED modules in the strip
Symbol HOW_MANY_LEDS = 144 '147/7
; Set the brightness of the LED while testing
; Use small values to keep current consumption low
Symbol BRIGHTNESS = 10 ; 0 to 255 (full)
; Initialise the HSPI interface
#macro init()
hspisetup spimode00, spifast
#endmacro
; Send a four byte packet out via HSPI
#macro sendPacket( n1, n2, n3, n4 )
hspiout( n1, n2, n3, n4 )
#endmacro
; Send the start of data header
#macro head()
sendPacket( $00, $00, $00, $00 )
#endmacro
; Send a LED controlling command
#macro send( red, green, blue)
sendPacket( $FF, blue, green, red )
#endmacro
; Send the end of data tail
#macro tail()
sendPacket( $FF, $FF, $FF, $FF )
'sendPacket( $FF, $FF, $FF, $FF )
'sendPacket( $FF, $FF, $FF, $FF )
#endmacro
PowerOnReset:
; Initialise the HSPI interface
init
TurnAllLedsOn:
; Turn all LED modules on
do
head
for w0 = 1 to HOW_MANY_LEDS step 6
send( BRIGHTNESS, $00, $00 ) ; red
send( $00, BRIGHTNESS, $00 ) ; green
send( $00, $00, BRIGHTNESS ) ; blue
send( BRIGHTNESS, BRIGHTNESS, $00 ) ; red + green
send( BRIGHTNESS, $00, BRIGHTNESS ) ; red + blue
send( $00, BRIGHTNESS, BRIGHTNESS ) ; green + blue
'send( BRIGHTNESS, BRIGHTNESS, BRIGHTNESS ) ; white
pause 50
next
tail
head
for w0 = 1 to HOW_MANY_LEDS step 6
send( BRIGHTNESS, $00, $00 ) ; red
send( BRIGHTNESS, $00, $00 ) ; red
send( BRIGHTNESS, $00, $00 ) ; red
send( BRIGHTNESS, $00, $00 ) ; red
send( BRIGHTNESS, $00, $00 ) ; red
send( BRIGHTNESS, $00, $00 ) ; red
'send( BRIGHTNESS, $00, $00 ) ; red
pause 50
next
tail
head
for w0 = 1 to HOW_MANY_LEDS step 6
send( $00, BRIGHTNESS, $00 ) ; green
send( $00, BRIGHTNESS, $00 ) ; green
send( $00, BRIGHTNESS, $00 ) ; green
send( $00, BRIGHTNESS, $00 ) ; green
send( $00, BRIGHTNESS, $00 ) ; green
send( $00, BRIGHTNESS, $00 ) ; green
'send( $00, BRIGHTNESS, $00 ) ; green
pause 50
next
tail
head
for w0 = 1 to HOW_MANY_LEDS step 6
send( $00, $00, BRIGHTNESS ) ; blue
send( $00, $00, BRIGHTNESS ) ; blue
send( $00, $00, BRIGHTNESS ) ; blue
send( $00, $00, BRIGHTNESS ) ; blue
send( $00, $00, BRIGHTNESS ) ; blue
send( $00, $00, BRIGHTNESS ) ; blue
'send( $00, $00, BRIGHTNESS ) ; blue
pause 50
next
tail
head
for w0 = 1 to HOW_MANY_LEDS step 6
send( $00, $00, $00) ; black
send( $00, $00, $00) ; black
send( $00, $00, $00) ; black
send( $00, $00, $00) ; black
send( $00, $00, $00) ; black
send( $00, $00, $00) ; black
'send( $00, $00, $00) ; black
pause 50
next
tail
loop
However this doesn't seem to work on my apa102 as it gets the lights to light up but with no significant correlation to the code,
I would like to start off my simply controlling specific leds and updating them when I need to. (NOTE: I am using a 60led/m strip).
What I would like to achieve:
Variable ---> is variable 3?
---> is variable 2
---------------------------------------↑ I know how to do the above ↑------------------------------
Attachments
-
299.4 KB Views: 9
-
92.8 KB Views: 9
-
28 KB Views: 8