Johnny-Five is the original JavaScript Robotics programming framework. Released by Bocoup in 2012, Johnny-Five is maintained by a community of passionate software developers and hardware engineers. Over 75 developers have made contributions towards building a robust, extensible and composable ecosystem.
This tutorial will tell you how to use Johnny-Five JavaScript programming framework to control GPIO on pcDuino3/pcDuino8 Uno.
Prerequisites
Hardware
- pcDuino3/3B or pcDuino8 Uno
Steps
1. Install a compatible version of node/npm
wget http://nodejs.org/dist/v0.10.24/node-v0.10.24-linux-arm-pi.tar.gz tar xvzf node-v0.10.24-linux-arm-pi.tar.gz <span class="pl-c1">cd</span> node-v0.10.24-linux-arm-pi sudo cp -R <span class="pl-k">*</span> /usr/local
2. Install Johnny-five and pcDuino-IO
Create a directory for your project, cd
into the directory and run the following:
npm init # follow the prompts npm config set strict-ssl false npm install johnny-five pcduino-io --save
3. “Blink” with Johnny-Five
Create a new JavaScript file.
vim blink.js <strong>Source code is :</strong>
var five = require("johnny-five"); var pcDuino = require("pcduino-io"); var board = new five.Board({ io: new pcDuino() }); board.on("ready", function() { var led = new five.Led(13); led.blink(); });
4. Run
node blink.js
Take pcDuino8 Uno as example, please check the LED1, is it blinking?
More information
Leave a Reply
You must be logged in to post a comment.