Using the color npm module

In order to use the color npm module, first we will install it. In your SSH session, in your project folder, run the following code:

npm i --save color

This will also save the color package to your package.json for code portability purposes. The module exports a function, which we will use to convert color strings like red or #FF0000 to an array of integers representing red, green, and blue. We will use these values to set our RGB LED. This is shown in the following example:

const Color = require('color')

let ledColor = Color('orange')
let ledRed = ledColor.red()
let ledGreen = ledColor.green()
let ledBlue = ledColor.blue()

We'll use this to help set the color of our RGB LED in our Johnny-Five program.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.199.122