August 2018
Beginner to intermediate
214 pages
6h 39m
English
The first thing we'll need is from the Raspi-IO README: we're going to read and run their led-blink code as our Hello World! Let's take a look at the code as a block:
const Raspi = require('raspi-io'); const five = require('johnny-five'); const board = new five.Board({ io: new Raspi() }); board.on('ready', () => { // Create an Led on pin 7 (GPIO4) on P1 and strobe it on/off // Optionally set the speed; defaults to 100ms (new five.Led('P1-7')).strobe(); });
This doesn't look like much, but there's a lot going on here! The first two lines use require to pull in the johnny-five and raspi-io modules. Then, we begin constructing a board object, and we pass a new instance of the raspi-io module in as its ...
Read now
Unlock full access