The idea is to have a method to stop and set the strip off and the other to select a couple of colors and play an animation, switching between those colors randomly.
To control the LED strip, we will use the lib
UPM jsupm_lpd8806 and to loop between the strip LEDs, we will need to use the
async module, which will provide us with asynchronous loops. Together with the
setTimeout method, this will help us keep the process non-blocking.
Firstly, let's start by installing the
async module by typing
npm install async inside the project folder (
chapter7). When it finishes installing, create a new file by typing
vi animations.js and paste the following code:
var LPD8806 = require('jsupm_lpd8806').LPD8806; var async = require('async'); var stripLength = 30; var ledstrip = new...