Skip to content

Instantly share code, notes, and snippets.

@iamdustan
Last active August 29, 2015 14:27
Show Gist options
  • Select an option

  • Save iamdustan/0fa5d7b9bb9854fa6728 to your computer and use it in GitHub Desktop.

Select an option

Save iamdustan/0fa5d7b9bb9854fa6728 to your computer and use it in GitHub Desktop.
Random demos to test react-hardware against Johnny-5
var five = require('johnny-five');
var board = new five.Board();
board.on('ready', function() {
var led = new five.Led(13);
var button = new five.Button(2);
// "down" the button is pressed
button.on("down", function() {
led.on();
});
// "hold" the button is pressed for specified time.
// defaults to 500ms (1/2 second)
// set
button.on("hold", function() {
console.log("hold");
});
// "up" the button is released
button.on("up", function() {
led.off();
});
});
var five = require("johnny-five");
var board = new five.Board();
board.on("ready", function() {
// Create an Led on pin 13
var led = new five.Led(9);
// Blink every half second
led.pulse(500);
});
var five = require("johnny-five");
var board = new five.Board();
board.on("ready", function() {
var servo = new five.Servo(9);
servo.sweep();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment