Hooloovoo
A superintelligent shade of the color blue.
This is a node.js library to control a APA102 RGB LED strip via SPI with your Raspberry Pi.
Control APA102 programmable LEDs with node.js
Installation
npm install hooloovoo
This module is located on npm as hooloovoo
Initialization
var hooloovoo = ;hooloovoo; // The number of LEDs
Parameters:
- the
number of LEDs
your apa102 strip has (32,60,...) - (optional) the
SPI clock
(must be a power of 2). Default is 128
Fill strip with one color
hooloovoo;
Set the whole strip the same color with a Hex value.
Parameters:
- A hex value. Between 000000 and FFFFFF
This example sets the all the LEDs in the strip red (FF0000)
hooloovoo;
Set the whole strip the same color with RGB values.
Parameters:
- red value (0 to 255)
- green value (0 to 255)
- blue value (0 to 255)
This example sets the all the LEDs in the strip red (255,0,0)
hooloovoo;
Since APA102 LED strips are BRG, there is an option to set them in their native format.
Parameters:
- blue value (0 to 255)
- green value (0 to 255)
- red value (0 to 255)
This example sets the all the LEDs in the strip red (0,0,255)
Set LED color individually
hooloovoo; // set LED1 to red
Parameters:
- Select an LED(0 to
number of LEDs
-1) - A hex value. Between 000000 and FFFFFF
This example sets LED 0
(first LED) red. (FF0000)
hooloovoo; // set LED1 to red
Parameters:
- Select an LED(0 to
number of LEDs
-1) - blue value (0 to 255)
- green value (0 to 255)
- red value (0 to 255)
This example sets LED 0
(first LED) red. (255,0,0)
hooloovoo; // set LED1 to red
Since APA102 LED strips are BRG, there is an option to set them in their native format. Parameters:
- Select an LED(0 to
number of LEDs
-1) - blue value (0 to 255)
- green value (0 to 255)
- red value (0 to 255)
This example sets LED 0
(first LED) red. (0,0,255)
Get the RGB value of a pixel
hooloovoo;
Returns an array of the RGB value of the targeted pixel
Parameters:
- the LED you want to know the RGB value of
hooloovoo; // if the LED was red, would return [255,0,0]
Turn off all the LEDs
hooloovooclear;
This turns off all the LEDs
Set the SPI clock
hooloovoo;
Parameters:
The SPI clock
(must be a power of 2). Default is 128
Send buffer to SPI
hooloovoo;
Sends all stored colors to the APA102 strip.
Not normally needed, but exposed for reasons.
Example
var hooloovoo = ; // connecting to Raspberry Pi hooloovoo; // assign number of APA102 LEDs, assign SPI clockhooloovoo; // OPTIONAL - Assign SPI clock - same as 2nd value of setup(), so unnecessary if you set it in setup(). Set this individually if you like. var led_count = 10; // set all colors to red console;hooloovoo; // after 2 seconds set first 6 LEDs to (red, green, blue, red, green, blue) ;
When running this example the LED strip will first fill all LEDs with red.
After 2 seconds it sets the color of the first 6 LEDs to (red, green, blue, red, green, blue).
Wiring the Raspberry Pi
Connect your Pi like this to the LED driver:
Raspberry Pi | led driver |
---|---|
GND | GND |
5V | input V+ |
SCLK | input CLK |
MOSI | input DIN |
I am not responsible for any damages to your hardware. Use this at your own risk.