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 chapter will tell you how to use Johnny-Five JavaScript programming framework to control GPIO on pcDuino8 Uno.
Steps
1. Install a compatible version of node/npm
sudo apt-install curl curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash - sudo apt-get install -y nodejs sudo apt-get install -y npm
2. Install Johnny-five and pcDuino-IO
Create a directory for your project, cd into the directory and run the following:
mkdir js cd js npm init 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
Source code is :
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?
Leave a Reply
You must be logged in to post a comment.