UNPKG

johnny-five

Version:

The JavaScript Arduino Programming Framework.

93 lines (62 loc) 1.6 kB
var five = require("../lib/johnny-five"); var moment = require("moment"); var temporal = require("temporal"); var readline = require("readline"); var rl = readline.createInterface({ input: process.stdin, output: process.stdout }); var board = new five.Board({ repl: false }); // var board = new five.Board(); board.on("ready", function() { var display = new five.Led.Digits({ pins: { data: 2, cs: 3, clock: 4, } }); display.on(); // this.repl.inject({ // display: display.device(0) // }); temporal.loop(1000, function() { var value = moment().format("hhmmssa"); // console.log( moment().format("hhmmssa") ); }); // var chars = Object.keys(five.Led.Digits.CHARS); // setInterval(function() { // var char = chars.shift(); // console.log( char ); // display.digit(0, char); // }, 1000); // var count = 0; // setInterval(function() { // if (count === 128) { // count = 0; // } // console.log( count ); // display.digit(0, count++); // }, 1000); var message = "hi Rose".split(""); message.forEach(function(letter, i) { display.digit(i, letter); }); rl.prompt(); rl.on("line", function(text) { // var template = "00000000"; // var length = text.length; // var first = text[0]; // var type = Number(first) === first ? "number" : "string"; // if (type === "string") { // } var args = text.trim().split(" "); if (args.length === 1) { args.unshift(0); } display.digit.apply(display, args); rl.prompt(); }); });