WS2801-Pi
Search…
Usage
WS2801-Pi can be used as follows:
1
import LedController from 'ws2801-pi';
2
// const LedController = require('ws2801-pi').default;
3
4
const amountOfLedsOnStrip = 100;
5
6
const ledController = new LedController(amountOfLedsOnStrip);
7
8
let color = {
9
red: 255,
10
green: 120,
11
blue: 0,
12
};
13
14
// Set color of whole led strip
15
ledController.fillLeds(color);
16
ledController.show();
17
18
color.red = 0;
19
color.green = 0;
20
color.blue = 255;
21
22
// Set color of single led
23
ledController.setLed(0, color);
24
ledController.show();
25
26
// Clear led strip (turn all leds off)
27
ledController
28
.clearLeds()
29
.show();
Copied!
Hint: Make sure to call show()after changing leds in order to physically change the leds.
Hint: If automaticRendering is set show() does not have to be called.
The rendering can then be awaited via ledController.renderPromise.
Last modified 1yr ago
Copy link