How to use the johnny-five.Leds function in johnny-five

To help you get started, we’ve selected a few johnny-five examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github willmendesneto / nodebots-workshop / src / second-example.js View on Github external
board.on('ready', function() {
  var leds = new five.Leds([12]);
  var buttons = new five.Buttons({
    pins: [13],
    // In case your buttons are responding to different events
    // they are probably receiving the eletricity in different points.
    // To solve that via code you can uncomment the option `invert`
    // invert: true
  });

  buttons.on('press', function(button) {
    var index = buttons.indexOf(button);
    leds[index].on();
    console.log('presssed', leds[index].pin);
  });

  buttons.on('release', function(button) {
    var index = buttons.indexOf(button);
github willmendesneto / nodebots-workshop / src / first-example.js View on Github external
board.on('ready', function() {

  // Number of the pin connected on the board
  var pinNumbers = [12];

  // Starting the LED
  var leds = new five.Leds(pinNumbers);

  // And here is the magic! \o/
  leds.blink();
  // leds.on();

  // How make the LED blink every second?
  // Blink accepts a number as timer parameter
  // The number value is based on miliseconds
  // So that, 1000 miliseconds = 1 seconds

  // leds.blink(1000);
});
github willmendesneto / nodebots-workshop / src / third-example.js View on Github external
board.on('ready', function() {
  var leds = new five.Leds([12]);
  var buttons = new five.Buttons({
    pins: [13],
    // In case your buttons are responding to different events
    // they are probably receiving the eletricity in different points.
    // To solve that via code you can uncomment the option `invert`
    // invert: true
  });
  var piezo = new five.Piezo(11);

  buttons.on('press', function(button) {
    var index = buttons.indexOf(button);
    leds[index].on();
    piezo.play({ song: 'C4' });
  });

  buttons.on('release', function(button) {
github AnnaGerber / node-ardx / code / CIRC02-code-leds.js View on Github external
board.on("ready", function() {
  var ledPins = [2,3,4,5,6,7,8,9];
  var leds = new five.Leds(ledPins);

  function oneAfterAnother() {
    var delay = 1;
    board.counter = 0;
    for (var i = 0; i < leds.length; i++) {
      var led = leds[i];

      board.wait(delay,function(){
        console.log(this.counter + " on")
        leds[this.counter].on();
      })
      board.wait(delay + 200,function(){
        console.log(this.counter + " off")
        leds[this.counter].off();
        this.counter = (this.counter + 1) % leds.length;
      })
github willmendesneto / nodebots-workshop / src / memory-game.js View on Github external
board.on('ready', function() {

  leds = new five.Leds([12, 3]);
  var buttons = new five.Buttons([13, 2]);

  piezo = new five.Piezo(11);

  buttons.on('press', function(button) {
    if (buttonsSequence.length) {
      var index = buttons.indexOf(button);
      leds[index].on();
      console.log('Pressed: button', button.pin, 'led', leds[index].pin);
      piezo.play({ song: piezoSongs[index] });
    }
  });

  buttons.on('release', function(button) {
    if (buttonsSequence.length) {
      var index = buttons.indexOf(button);
github rwaldron / johnny-five / eg / arduino-starter-kit / spaceship-interface.js View on Github external
board.on("ready", function() {

  var leds = five.Leds([3,4,5]);
  var btn = five.Button(2);

  btn.on("press", function() {
    leds[0].off();
    leds[1].on().blink(500);
    leds[2].off().blink(500);
  });

  btn.on("release", function() {
    leds[0].on();
    leds[1].off().stop();
    leds[2].off().stop();
  });

});
github rwaldron / johnny-five / eg / arduino-starter-kit / love-o-meter.js View on Github external
board.on("ready", function() {

  var leds = five.Leds([2, 3, 4]);

  var tmp = new five.Thermometer({
    controller: "TMP36",
    pin: "A0"
  });

  tmp.on("change", function() {
    if (this.celsius >= 22) {
      leds[0].on();
    } else {
      leds[0].off();
    }
    if (this.celsius >= 24) {
      leds[1].on();
    } else {
      leds[1].off();
github rwaldron / johnny-five / eg / arduino-starter-kit / digital-hourglass.js View on Github external
board.on("ready", function() {
  var leds = new five.Leds([2, 3, 4, 5, 6, 7]);
  var tilt = new five.Sensor.Digital(8);
  var i = 0;
  this.loop(1000 * 60 * 10, function() {
    leds[i].on();
    i = (i + 1) % 6;
  });
  tilt.on("change", function() {
    i = 0;
    leds.off();
  });
});

johnny-five

The JavaScript Robotics and Hardware Programming Framework. Use with: Arduino (all models), Electric Imp, Beagle Bone, Intel Galileo & Edison, Linino One, Pinoccio, pcDuino3, Raspberry Pi, Particle/Spark Core & Photon, Tessel 2, TI Launchpad and more!

MIT
Latest version published 3 years ago

Package Health Score

56 / 100
Full package analysis