Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 19:19 10 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : APA 102 LED Strip

Author Message
Bill.b

Senior Member

Joined: 25/06/2011
Location: Australia
Posts: 239
Posted: 06:08pm 31 Jan 2016
Copy link to clipboard 
Print this post

Hi all

I have been playing with a 1m length of 60 APA 102 RGB leds for my Christmas
light displays.

Here is the program I have been using to test the LEDS. also a youtube
video of the results. The code is not pretty as it has been built up as I added different patterns and tried different ways to use the LEDs.

The beauty of the APA 102 LEDs are that they do not require any Cfunction code.

The APA 102 require a 5v supply but the clock and data inputs work quite well on 3.3v
from the PICMX170.

https://www.youtube.com/watch?v=IRmtGD0kJVo

[code]
'Test Program for APA102 60 RGB LED Strip
Option autorun on
Option DEFAULT NONE
cpu 48
' Option EXPLICIT
randomize timer
Dim integer count, count1, rndnum, loopcnt, indexcount
Dim INTEGER NUMLEDS=60
Dim integer buffer(183)
Dim integer red1, red
Dim integer green1, green
Dim integer blue1, blue
SPI open 5000000, 3,8
For count = 0 To 180 'Reset all LED to OFF
buffer(count) = 0
Next count
sendLED
Pause 100

main

Sub app102Head ' Send the start of data header
SPI write 4, &H00,&H00,&H00,&H00
End Sub

Sub app102tail 'Send the end of data tail
SPI write 4, &HFF,&HFF,&HFF,&HFF
End Sub

Sub main
Do
for count1 = 1 to 6
getcolour 'set colour randomly
'Flash all leds
For count = 0 To 178 Step 3
buffer(count) = Red 'RED
buffer(count+1) = green 'Green
buffer(count+2) = blue 'Blue
Next count
sendLED
Pause 1000
next count1
Pause 1000

For count = 0 To 180 'turn all leds OFF
buffer(count) = 0
Next count
sendLED
getcolour 'set colour randomly
for loopcnt = 1 to 4
For count1 = 0 To 178 Step 3
buffer(count1) = red
buffer(count1+1) = green
buffer(count1+2) = blue
sendLED
Pause 20
Next count1
getcolour

For count1 = 183 To 2 Step -3
buffer(count1-2) = red
buffer(count1-1) = green
buffer(count1) = blue
sendLED
Pause 10
Next count1
next loopcnt
pause 1000
For count = 0 To 180 'Reset all LED to OFF
buffer(count) = 0
Next count
sendLED
' Random display
Pause 100
for count1 = 1 to 150 'repeat random lights 150 times
for count = 0 to 5
rndnum = Int(RND()*180)+1 'Set array size and set data - Number of LEDs * 3
Buffer(rndnum) = count * 10 and 10 'Set Brightness of LED
next count
sendLED
pause 100
next count1
sendLED
pause 900
'Kit scanner
For count = 0 To 183 'turn all leds OFF
buffer(count) = 0
Next count
sendLED
for loopcnt = 1 to 2
for count1 = 5 to 180 step 3 'Run the Red LED from end to end and return
Buffer(count1) = 30
sendLED
Buffer(count1-3) = 0
sendLED
next count1
for count1 = 179 to 0 step -3
Buffer(count1) = 30
sendLED
Buffer(count1+3) = 0
sendLED
next count1
next loopcnt
pause 10
for count1 = 1 to 12
for loopcnt = 0 to 179
read buffer(loopcnt)
next loopcnt
sendLED
pause 50
next count1
pause 2000
restore


For count = 0 To 183 'turn all leds OFF
buffer(count) = 0
Next count
sendLED
For count = 0 To 183 step 3 'turn all leds OFF
buffer(count) = 1
Next count
sendLED
indexcount = 180
for loopcnt = 1 to 60
for count1 = 5 to indexcount step 3 'Run the Red LED from end to end and return
Buffer(count1) = 30
sendLED
Buffer(count1-3) = 0
sendLED
next count1
indexcount = indexcount -3
next loopcnt

For count = 0 To 180 'turn all leds OFF
buffer(count) = 0
Next count
sendLED
For count = 0 To 180 step 3 'turn all leds OFF
buffer(count+2) = 1
Next count
sendLED
indexcount = 180
for loopcnt = 1 to 60
for count1 = 4 to indexcount step 3 'Run the Red LED from end to end and return
Buffer(count1) = 30
sendLED
Buffer(count1-3) = 0
sendLED
next count1
indexcount = indexcount -3
next loopcnt

Loop

Sub sendLED ' Send a LED controlling command
app102head
For count = 0 To 178 Step 3
red1 = buffer(count)
green1 = buffer(count + 1)
blue1 = buffer(count + 2)
SPI write 4, &HFF, red1, green1, blue1
Next count
app102tail
End Sub

'get random colour
sub getcolour
red = Int(RND()*5)+1
red = red * 10 and 10
green = Int(RND()*5)+1
green = green * 10 and 10
blue = Int(RND()*5)+1
blue = blue * 10 and 10
end sub

' Data for LED strip 00 = OFF 255 = Max ON 30 is normal brightness LED Number

'| B G R| B G R |B G R| B G R| B G R| B G R| B G R| B G R| B G R| B G R|
data 30,00,00,00,30,00,00,00,30,30,00,00,00,30,00,00,00,30,00,00,00,00,00,00,00,00,00,00,00,00 ' 1 to 10
data 30,00,00,00,30,00,00,00,30,30,00,00,00,30,00,00,00,30,00,00,00,00,00,00,00,00,00,00,00,00 ' 11 to 20
data 30,00,00,00,30,00,00,00,30,30,00,00,00,30,00,00,00,30,00,00,00,00,00,00,00,00,00,00,00,00 ' 21 to 30
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,30,00,30,30 ' 31 to 40
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,30,00,30,30 ' 41 to 50
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,30,00,30,30 ' 51 to 60

'| B G R| B G R |B G R| B G R| B G R| B G R| B G R| B G R| B G R| B G R|
data 00,00,30,30,00,00,00,30,00,00,00,30,30,00,00,00,30,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 1 to 10
data 00,00,30,30,00,00,00,30,00,00,00,30,30,00,00,00,30,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 11 to 20
data 00,00,30,30,00,00,00,30,00,00,00,30,30,00,00,00,30,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 21 to 30
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,30,00,30,30,00,00,00 ' 31 to 40
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,30,00,30,30,00,00,00 ' 41 to 50
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,30,00,30,30,00,00,00 ' 51 to 60

'| B G R| B G R |B G R| B G R| B G R| B G R| B G R| B G R| B G R| B G R|
data 00,30,00,00,00,30,30,00,00,00,30,00,00,00,30,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 1 to 10
data 00,30,00,00,00,30,30,00,00,00,30,00,00,00,30,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 11 to 20
data 00,30,00,00,00,30,30,00,00,00,30,00,00,00,30,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 21 to 30
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,30,00,30,30,00,00,00,00,00,00 ' 31 to 40
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,30,00,30,30,00,00,00,00,00,00 ' 41 to 50
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,30,00,30,30,00,00,00,00,00,00 ' 51 to 60

'| B G R| B G R |B G R| B G R| B G R| B G R| B G R| B G R| B G R| B G R|
data 00,30,00,00,00,30,30,00,00,00,30,00,00,00,30,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 1 to 10
data 00,30,00,00,00,30,30,00,00,00,30,00,00,00,30,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 11 to 20
data 00,30,00,00,00,30,30,00,00,00,30,00,00,00,30,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 21 to 30
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,30,00,30,30,00,00,00,00,00,00,00,00,00 ' 31 to 40
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,30,00,30,30,00,00,00,00,00,00,00,00,00 ' 41 to 50
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,30,00,30,30,00,00,00,00,00,00,00,00,00 ' 51 to 60

'| B G R| B G R |B G R| B G R| B G R| B G R| B G R| B G R| B G R| B G R|
data 00,00,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 1 to 10
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 11 to 20
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30 ' 21 to 30
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 31 to 40
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 41 to 50
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30 ' 51 to 60

'| B G R| B G R |B G R| B G R| B G R| B G R| B G R| B G R| B G R| B G R|
data 00,00,30,00,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 1 to 10
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 11 to 20
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,00,00,30 ' 21 to 30
data 00,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 31 to 40
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 41 to 50
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,00,00,30 ' 51 to 60

'| B G R| B G R |B G R| B G R| B G R| B G R| B G R| B G R| B G R| B G R|
data 00,00,30,00,30,00,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 1 to 10
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 11 to 20
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,00,00,30,00,00,00,30 ' 21 to 30
data 00,30,00,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 31 to 40
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 41 to 50
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,00,00,30,00,00,00,30 ' 51 to 60

'| B G R| B G R |B G R| B G R| B G R| B G R| B G R| B G R| B G R| B G R|
data 00,00,30,00,30,00,30,00,00,00,30,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 1 to 10
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 11 to 20
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,30,30,00,00,00,30,00,00,00,30 ' 21 to 30
data 00,30,00,30,00,00,00,03,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 31 to 40
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 41 to 50
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,30,30,00,00,00,30,00,00,00,30 ' 51 to 60

'| B G R| B G R |B G R| B G R| B G R| B G R| B G R| B G R| B G R| B G R|
data 00,00,30,00,30,00,30,00,00,00,30,30,30,00,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 1 to 10
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 11 to 20
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,30,00,30,30,30,00,00,00,30,00,00,00,30 ' 21 to 30
data 00,30,00,30,00,00,00,03,30,30,00,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 31 to 40
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 41 to 50
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,30,00,30,30,30,00,00,00,30,00,00,00,30 ' 51 to 60

'| B G R| B G R |B G R| B G R| B G R| B G R| B G R| B G R| B G R| B G R|
data 00,00,30,00,30,00,30,00,00,00,30,30,30,00,30,30,30,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 1 to 10
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 11 to 20
data 00,00,00,00,00,00,00,00,00,00,00,00,30,30,00,30,00,30,00,30,30,30,00,00,00,30,00,00,00,30 ' 21 to 30
data 00,30,00,30,00,00,00,03,30,30,00,30,30,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 31 to 40
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 41 to 50
data 00,00,00,00,00,00,00,00,00,00,00,00,30,30,00,30,00,30,00,30,30,30,00,00,00,30,00,00,00,30 ' 51 to 60

'| B G R| B G R |B G R| B G R| B G R| B G R| B G R| B G R| B G R| B G R|
data 00,00,30,00,30,00,30,00,00,00,30,30,30,00,30,30,30,00,30,30,30,00,00,00,00,00,00,00,00,00 ' 1 to 10
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 11 to 20
data 00,00,00,00,00,00,00,00,00,30,30,30,30,30,00,30,00,30,00,30,30,30,00,00,00,30,00,00,00,30 ' 21 to 30
data 00,30,00,30,00,00,00,03,30,30,00,30,30,30,00,30,30,30,00,00,00,00,00,00,00,00,00,00,00,00 ' 31 to 40
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 41 to 50
data 00,00,00,00,00,00,00,00,00,30,30,30,30,30,00,30,00,30,00,30,30,30,00,00,00,30,00,00,00,30 ' 51 to 60

'| B G R| B G R |B G R| B G R| B G R| B G R| B G R| B G R| B G R| B G R|
data 00,00,30,00,30,00,30,00,00,00,30,30,30,00,30,30,30,00,30,30,30,10,10,20,30,00,10,00,00,00 ' 1 to 10
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 11 to 20
data 00,00,00,30,00,10,10,10,20,30,30,30,30,30,00,30,00,30,00,30,30,30,00,00,00,30,00,00,00,30 ' 21 to 30
data 00,30,00,30,00,00,00,30,30,30,00,30,30,30,00,30,30,30,10,10,20,30,00,10,00,00,00,00,00,00 ' 31 to 40
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 41 to 50
data 00,00,00,30,00,10,10,10,20,30,30,30,30,30,00,30,00,30,00,30,30,30,00,00,00,30,00,00,00,30 ' 51 to 60
[/code]








The 100r resistors are to protect the inputs of the 170 if a fault develops in the LEDS.

Bill


Edited by Bill.b 2016-02-02
In the interests of the environment, this post has been constructed entirely from recycled electrons.
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 979
Posted: 08:55pm 31 Jan 2016
Copy link to clipboard 
Print this post

VERY NICE!

It's very impressive!

Frank
 
cicciocb
Regular Member

Joined: 29/04/2014
Location: France
Posts: 72
Posted: 12:53am 01 Feb 2016
Copy link to clipboard 
Print this post

Hello,
theoretically even the WS2812B can be driven with the SPI; it's more tricky but is how I did in another project.
However I don't know if this will be possible with the micromite.

Cicciocb
 
Bill.b

Senior Member

Joined: 25/06/2011
Location: Australia
Posts: 239
Posted: 01:20am 01 Feb 2016
Copy link to clipboard 
Print this post

Hi Cicciocb

The ws2812b are not true SPI as they only require a single data line.
The data has to be loaded at a frequency of 800kHz, difficult for MMbasic
to do with out using a cFunction to control the timers.

See the post

http://www.thebackshed.com/forum/forum_posts.asp?TID=7420&PN=1

Bill
In the interests of the environment, this post has been constructed entirely from recycled electrons.
 
cicciocb
Regular Member

Joined: 29/04/2014
Location: France
Posts: 72
Posted: 02:43am 01 Feb 2016
Copy link to clipboard 
Print this post

I know, it's the reason for why I said that is a little bit "tricky" to do.
if you put a SPI at 2.5MHz, you can cheat it.
Looking at the documentation of the WS2812B, the "0" and the "1" are simply pulses of 1.2us; the difference is that the "0" is a logic high for 0.4us and the "1" is a logic high for 0.8us.

So, taking this into account, you can consider that, with the SPI, one WS2812B bit can be composed of 3 SPI bits where the "0" is a sequence of "100" and the "1" is a sequence of "110".

As at 2.5Mhz of SPI, the each bit is 0.4us, you can do the job!

This means that a "WS2812B" byte can be "simulated" with 3 SPI bytes and, globally, you need 9 bytes per each led.

For sure, you don't require the CLK signal but only the DOUT.

I think it should work also for the micromite without requiring any cfunction.

Regards,
CicciocbEdited by cicciocb 2016-02-02
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 09:52am 02 Feb 2016
Copy link to clipboard 
Print this post

Hi Billb, this is very nice. Thank you for posting. Just ordered some apa leds and will try when they arrive. Great Work!!!
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 11:31pm 29 Oct 2017
Copy link to clipboard 
Print this post

  Bill.b said  
' Data for LED strip 00 = OFF 255 = Max ON 30 is normal brightness LED Number

'| B G R| B G R |B G R| B G R| B G R| B G R| B G R| B G R| B G R| B G R|
data 30,00,00,00,30,00,00,00,30,30,00,00,00,30,00,00,00,30,00,00,00,00,00,00,00,00,00,00,00,00 ' 1 to 10
data 30,00,00,00,30,00,00,00,30,30,00,00,00,30,00,00,00,30,00,00,00,00,00,00,00,00,00,00,00,00 ' 11 to 20
data 30,00,00,00,30,00,00,00,30,30,00,00,00,30,00,00,00,30,00,00,00,00,00,00,00,00,00,00,00,00 ' 21 to 30
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,30,00,30,30 ' 31 to 40
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,30,00,30,30 ' 41 to 50
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,30,00,30,30 ' 51 to 60

'| B G R| B G R |B G R| B G R| B G R| B G R| B G R| B G R| B G R| B G R|
data 00,00,30,30,00,00,00,30,00,00,00,30,30,00,00,00,30,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 1 to 10
data 00,00,30,30,00,00,00,30,00,00,00,30,30,00,00,00,30,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 11 to 20
data 00,00,30,30,00,00,00,30,00,00,00,30,30,00,00,00,30,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 21 to 30
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,30,00,30,30,00,00,00 ' 31 to 40
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,30,00,30,30,00,00,00 ' 41 to 50
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,30,00,30,30,00,00,00 ' 51 to 60

'| B G R| B G R |B G R| B G R| B G R| B G R| B G R| B G R| B G R| B G R|
data 00,30,00,00,00,30,30,00,00,00,30,00,00,00,30,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 1 to 10
data 00,30,00,00,00,30,30,00,00,00,30,00,00,00,30,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 11 to 20
data 00,30,00,00,00,30,30,00,00,00,30,00,00,00,30,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 21 to 30
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,30,00,30,30,00,00,00,00,00,00 ' 31 to 40
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,30,00,30,30,00,00,00,00,00,00 ' 41 to 50
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,30,00,30,30,00,00,00,00,00,00 ' 51 to 60

'| B G R| B G R |B G R| B G R| B G R| B G R| B G R| B G R| B G R| B G R|
data 00,30,00,00,00,30,30,00,00,00,30,00,00,00,30,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 1 to 10
data 00,30,00,00,00,30,30,00,00,00,30,00,00,00,30,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 11 to 20
data 00,30,00,00,00,30,30,00,00,00,30,00,00,00,30,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 21 to 30
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,30,00,30,30,00,00,00,00,00,00,00,00,00 ' 31 to 40
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,30,00,30,30,00,00,00,00,00,00,00,00,00 ' 41 to 50
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,30,00,30,30,00,00,00,00,00,00,00,00,00 ' 51 to 60

'| B G R| B G R |B G R| B G R| B G R| B G R| B G R| B G R| B G R| B G R|
data 00,00,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 1 to 10
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 11 to 20
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30 ' 21 to 30
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 31 to 40
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 41 to 50
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30 ' 51 to 60

'| B G R| B G R |B G R| B G R| B G R| B G R| B G R| B G R| B G R| B G R|
data 00,00,30,00,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 1 to 10
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 11 to 20
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,00,00,30 ' 21 to 30
data 00,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 31 to 40
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 41 to 50
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,00,00,30 ' 51 to 60

'| B G R| B G R |B G R| B G R| B G R| B G R| B G R| B G R| B G R| B G R|
data 00,00,30,00,30,00,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 1 to 10
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 11 to 20
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,00,00,30,00,00,00,30 ' 21 to 30
data 00,30,00,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 31 to 40
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 41 to 50
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,00,00,30,00,00,00,30 ' 51 to 60

'| B G R| B G R |B G R| B G R| B G R| B G R| B G R| B G R| B G R| B G R|
data 00,00,30,00,30,00,30,00,00,00,30,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 1 to 10
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 11 to 20
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,30,30,00,00,00,30,00,00,00,30 ' 21 to 30
data 00,30,00,30,00,00,00,03,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 31 to 40
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 41 to 50
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,30,30,00,00,00,30,00,00,00,30 ' 51 to 60

'| B G R| B G R |B G R| B G R| B G R| B G R| B G R| B G R| B G R| B G R|
data 00,00,30,00,30,00,30,00,00,00,30,30,30,00,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 1 to 10
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 11 to 20
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,30,00,30,30,30,00,00,00,30,00,00,00,30 ' 21 to 30
data 00,30,00,30,00,00,00,03,30,30,00,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 31 to 40
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 41 to 50
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,30,00,30,00,30,30,30,00,00,00,30,00,00,00,30 ' 51 to 60

'| B G R| B G R |B G R| B G R| B G R| B G R| B G R| B G R| B G R| B G R|
data 00,00,30,00,30,00,30,00,00,00,30,30,30,00,30,30,30,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 1 to 10
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 11 to 20
data 00,00,00,00,00,00,00,00,00,00,00,00,30,30,00,30,00,30,00,30,30,30,00,00,00,30,00,00,00,30 ' 21 to 30
data 00,30,00,30,00,00,00,03,30,30,00,30,30,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 31 to 40
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 41 to 50
data 00,00,00,00,00,00,00,00,00,00,00,00,30,30,00,30,00,30,00,30,30,30,00,00,00,30,00,00,00,30 ' 51 to 60

'| B G R| B G R |B G R| B G R| B G R| B G R| B G R| B G R| B G R| B G R|
data 00,00,30,00,30,00,30,00,00,00,30,30,30,00,30,30,30,00,30,30,30,00,00,00,00,00,00,00,00,00 ' 1 to 10
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 11 to 20
data 00,00,00,00,00,00,00,00,00,30,30,30,30,30,00,30,00,30,00,30,30,30,00,00,00,30,00,00,00,30 ' 21 to 30
data 00,30,00,30,00,00,00,03,30,30,00,30,30,30,00,30,30,30,00,00,00,00,00,00,00,00,00,00,00,00 ' 31 to 40
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 41 to 50
data 00,00,00,00,00,00,00,00,00,30,30,30,30,30,00,30,00,30,00,30,30,30,00,00,00,30,00,00,00,30 ' 51 to 60

'| B G R| B G R |B G R| B G R| B G R| B G R| B G R| B G R| B G R| B G R|
data 00,00,30,00,30,00,30,00,00,00,30,30,30,00,30,30,30,00,30,30,30,10,10,20,30,00,10,00,00,00 ' 1 to 10
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 11 to 20
data 00,00,00,30,00,10,10,10,20,30,30,30,30,30,00,30,00,30,00,30,30,30,00,00,00,30,00,00,00,30 ' 21 to 30
data 00,30,00,30,00,00,00,30,30,30,00,30,30,30,00,30,30,30,10,10,20,30,00,10,00,00,00,00,00,00 ' 31 to 40
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ' 41 to 50
data 00,00,00,30,00,10,10,10,20,30,30,30,30,30,00,30,00,30,00,30,30,30,00,00,00,30,00,00,00,30 ' 51 to 60
[/code]


I don't get what the above actually does?
You said 255 = max but where would you put the 255 and what do each of those lines above actually do?
*trying to understand it*
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2959
Posted: 09:17am 30 Oct 2017
Copy link to clipboard 
Print this post

Great stuff Bill - can't wait to see your 'show' for this Christmas!!

One thing I found with the APAs, the recommended is to power these LED strings at 5v. The logic high out of the MM is 3v3 (typically) which falls just short of the recommended 0.7*Vdd of the APA to guarantee a 'high' data level.

Even though 3v3 'highs' do indeed appear to drive the APA correctly, IF you feed the data fast from the MM into the APA then the quality of signal drops. This is clearly seen if you try do a smooth (and fast) brightness fade (up or down). It becomes not very smooth.

Two solutions I found without any 'level shifting'. Power the APAs at 3v3, OR increase MM voltage from 3v3 to 3v6.

For anyone wanting to play with these brilliant RGB LEDs, I have some shorter strips becoming available for use with Peter's HAT Stand (PCBs arriving this week).
 
Bill.b

Senior Member

Joined: 25/06/2011
Location: Australia
Posts: 239
Posted: 12:16am 31 Oct 2017
Copy link to clipboard 
Print this post

@lew247
  Quote   don't get what the above actually does?
You said 255 = max but where would you put the 255 and what do each of those lines above actually do?
*trying to understand it*


Though the spec for the apa102 states that the value for full range is 0 - 255
I found that a value of 30 achieves near max brightness and minimizes the total current drawn by the strip.

BillEdited by Bill.b 2017-11-01
In the interests of the environment, this post has been constructed entirely from recycled electrons.
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 01:36am 31 Oct 2017
Copy link to clipboard 
Print this post

Thanks Bill,
but what do all the lines actually do? are they needed? where do they go and how does the program access them?
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2959
Posted: 05:34am 31 Oct 2017
Copy link to clipboard 
Print this post

@lew247,

In Bill's code, there is a section as follows:


for count1 = 1 to 12
for loopcnt = 0 to 179
read buffer(loopcnt)
next loopcnt
sendLED
pause 50
next count1


There are two loops here; the inner one performs 180 READs and reads a 'chunk' of the DATA i.e. the numbers 00 or 30. 00 means LED OFF, 30 means ON. Each LED has three bits of data (for Blue, Green and Red). So the first three data elements in the first of 12 chunks is 30, 00, 00 which equates to BLUE (i.e. B=ON, G=OFF, R=OFF).
The sendLED sub called simply sends the data to the LEDs so they become 'visible'

The 'outer' loop repeats this process 12 times to read all the 12 chunks of data.

Hope this helps . . . .

WW
 
Bill.b

Senior Member

Joined: 25/06/2011
Location: Australia
Posts: 239
Posted: 11:31am 07 Dec 2017
Copy link to clipboard 
Print this post

[quote]Great stuff Bill - can't wait to see your 'show' for this Christmas!! [/quote]

2017 lights

https://www.youtube.com/watch?v=E7vkjcxWzWE


Bill

In the interests of the environment, this post has been constructed entirely from recycled electrons.
 
Azure

Guru

Joined: 09/11/2017
Location: Australia
Posts: 446
Posted: 12:09pm 07 Dec 2017
Copy link to clipboard 
Print this post

  Bill.b said   [quote]Great stuff Bill - can't wait to see your 'show' for this Christmas!! [/quote]

2017 lights

https://www.youtube.com/watch?v=E7vkjcxWzWE


Bill


Bill, keen to watch the linked video but it reports as unavailable. Has it finished uploading and passed checking?
 
Bill.b

Senior Member

Joined: 25/06/2011
Location: Australia
Posts: 239
Posted: 09:32pm 07 Dec 2017
Copy link to clipboard 
Print this post

It shold be OK now. was set to private. now is public.


Bill
Edited by Bill.b 2017-12-09
In the interests of the environment, this post has been constructed entirely from recycled electrons.
 
kg4pid
Regular Member

Joined: 08/03/2015
Location: United States
Posts: 50
Posted: 10:58pm 07 Dec 2017
Copy link to clipboard 
Print this post

  Bill.b said  
2017 lights

https://www.youtube.com/watch?v=E7vkjcxWzWE


Bill


Santa shouldn't have any problem finding your house!

Max
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1667
Posted: 10:50am 08 Dec 2017
Copy link to clipboard 
Print this post

Simply Superb Bill,

and Christmas Lights they are,
not any other "Correct: term that could be used.
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3466
Posted: 03:00pm 08 Dec 2017
Copy link to clipboard 
Print this post

Spectacular they are. Which ones are new?

  kg4pid said  ... Santa shouldn't have any problem finding your house! ...


Your real worry might be that he will raid it to give his elves something to aspire to--industrial espionage.


PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025