WS2812B RGB LED controller library

Thumbnail

Favourites: 0

Report File

WS2812B RGB LED controller library


File Information



Files




Here's a library for interfacing with the WS2812B RGB LED controllers.

It can control as many controllers as the RAM on the PIC micro device allows, as each WS2812B has its own RAM allocated within a 32-bit array for Red, Green and Blue. Later I will upload a library for the SK6812 controllers, which allow Red, Green, Blue, and White.

Note that the library has no assembler routines within it, as the compiler does not need to drop to asm, unlike virtually all other compiler libraries for these devices.

I'll upload a more advanced demo program later, but the library include file has many comments so it should be pretty straightforward to understand. But here's a simple demo:

' WS2812B RGB Interface
'
Device = 18F25K20
Declare Xtal = 64

$define WS2812B_Pin PORTB.0 ' Assign the pin used for the WS2812B devices
$define WS2812B_Amount 64 ' The amount of WS2812B devices on the line

Include "WS2812B.inc" ' Load the RGB WS2812B routines into the program

Dim ChipNumber As Byte
Dim Red[WS2812B_Amount] As Byte
Dim Green[WS2812B_Amount] As Byte
Dim Blue[WS2812B_Amount] As Byte

'---------------------------------------------------------------------------------------------
' The main program starts here
'
Main:
Do
Clear Green
Clear Blue
Set Red
For ChipNumber = 0 To WS2812B_Amount - 1
WS2812B_Colour(ChipNumber, Red[ChipNumber], Green[ChipNumber], Blue[ChipNumber])
DelayMS 5
Next

Set Green
For ChipNumber = 0 To WS2812B_Amount - 1
WS2812B_Colour(ChipNumber, Red[ChipNumber], Green[ChipNumber], Blue[ChipNumber])
DelayMS 5
Next

Set Blue
For ChipNumber = 0 To WS2812B_Amount - 1
WS2812B_Colour(ChipNumber, Red[ChipNumber], Green[ChipNumber], Blue[ChipNumber])
DelayMS 5
Next

Clear Red
Clear Blue
For ChipNumber = 0 To WS2812B_Amount - 1
WS2812B_Colour(ChipNumber, Red[ChipNumber], Green[ChipNumber], Blue[ChipNumber])
DelayMS 5
Next
Loop

Report File

Reason












Report Comment

Reason






Report Link

Reason