Skip to content

Instantly share code, notes, and snippets.

@dan-mckay
Created April 15, 2013 23:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dan-mckay/5392221 to your computer and use it in GitHub Desktop.
Save dan-mckay/5392221 to your computer and use it in GitHub Desktop.
This is a simple script to demonstrate the REPL provided by johnny-five for interaction with an LED connected to an Arduino.
var five = require("johnny-five"),
board, led;
board = new five.Board();
board.on("ready", function() {
// Create a standard `led` hardware instance
led = new five.Led(9);
// pinMode is set to OUTPUT by default
// Inject the `led` hardware into
// the Repl instance's context;
// allows direct command line access
board.repl.inject({
led: led
});
// "fade" to the value, 0-255, in the given time.
// Defaults to 1000ms
// pinMode will be changed to PWM automatically
//
// led.fade( 255, 3000 );
led.fadeIn();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment