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); });
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); leds.off(); console.log('released'); }); });
board.on('ready', function() { leds = new five.Leds([12, 3]); var buttons = new five.Buttons([13, 2]);
board.on('ready', function() { leds = new five.Leds([12, 3]); var buttons = new five.Buttons([13, 2]);
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) { var index = buttons.indexOf(button); leds[index].off(); piezo.off(); }); });