Created
October 29, 2014 00:14
-
-
Save krist00fer/7a955632477dcd754138 to your computer and use it in GitHub Desktop.
Blink led on Tessel device a specific amount of times
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var tessel = require('tessel'); | |
function blink(ledNo, noTimes, callback) { | |
if (noTimes > 0) { | |
var led = tessel.led[ledNo].output(0); | |
var lightOnDelay = 500; | |
var lightOffDelay = 1000; | |
console.log('blink - turning on led (%d)', noTimes); | |
led.write(true); | |
setTimeout(function(){ | |
console.log('blink - turning off led'); | |
led.write(false); | |
setTimeout(blink, lightOffDelay, ledNo, noTimes - 1, callback); | |
}, lightOnDelay); | |
} | |
else { | |
callback(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment