A UDP based message module for nodeJS for controlling a WS2812 LED strip
npm install lednetnpm i -s lednet - it can be used immediately.
javascript
const led = require("lednet")();
(async function () {
const clients = await led.discoverClients();
console.log(Found client at ${clients[0].address});
const client = clients[0];
client.configure({leds: 144, type: "grb"});
setInterval(() => {
client.tweenToColor(Math.random() 255, Math.random() 255, Math.random() * 255);
}, 2000);
})();
`
Client
The client runs on a raspberry pi with a connected WS2812 LED strip. It will process command messages
sent via UDP from a client in the same network and apply the commands on the LED strip.
For testing and/or debugging purposes, the client can also be started without a LED strip connected, or even
without running it on a raspberry. The hardware simulator will open in your browser and show live updates.
!Screenshot of the hardware simulator
$3
Check out the project code to your harddrive. Run npm i in the project root. All sub dependencies for the client and
client UI will be installed as well.
> __Don't be afraid if the install fails!__
> This will most likely happen, because the npm module that is used to actually control the hardware on the raspberry pi
> will only install correctly on a raspberry pi.
To start the client simulator, execute npm run clientSimulator. You should see the messages "Using Browser Test Connector"
and "LED net client started".
To actually see something, you need to start the UI in a separate shell with npm run clientUI`. The UI should open in your