-
-
Save dorantor/9be4206404f69683c203 to your computer and use it in GitHub Desktop.
First program for Espruino.
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
Bool = function (v) { | |
if (v) { | |
return true; | |
} | |
return false; | |
}; | |
doCount = function (count) { | |
if (count < positions_amount) { | |
return count+1; | |
} | |
return 0; | |
}; | |
updateLeds = function (count) { | |
LED1.write( | |
Bool(positions[count] & leds.LED1) | |
); | |
LED2.write( | |
Bool(positions[count] & leds.LED2) | |
); | |
LED3.write( | |
Bool(positions[count] & leds.LED3) | |
); | |
}; | |
var leds = { | |
LED1: 1, | |
LED2: 2, | |
LED3: 4 | |
}; | |
var positions = [4,2,1,0,1,2,4,0,4,6,7,3,1,0,1,3,7,6,4,0,5,2,2,2,5,0]; | |
var positions_amount = 26; | |
var count = 0; | |
function main() { | |
count = doCount(count); | |
updateLeds(count); | |
} | |
function onInit() { | |
clearInterval(); | |
setInterval(main, 100); | |
} | |
function buttonWatcher(e) { | |
onInit(); | |
console.log('pressed'); | |
} | |
setWatch(buttonWatcher, BTN1, {edge:"falling", repeat:true}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment