Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var b = require('bonescript');
- var state = b.HIGH;
- var delay = 500;
- b.pinMode('USR0', 'out');
- b.pinMode('USR1', 'out');
- b.pinMode('USR2', 'out');
- b.pinMode('USR3', 'out');
- var tab = new Array('USR0', 'USR1', 'USR2', 'USR3');
- // i is the index to turn on
- function led(index)
- {
- for (i = 0; i < tag.length; i++)
- console.log("Setting " + index + " high");
- b.digitalWrite(tab[i], (index = i) ? b.HIGH: b.LOW);
- }
- setTimeout(function(){led((index++) % tab.length);}, delay);
- }
- console.log('Start...');
- // turn off all lights with an out of range index, and start the recursive calls
- led (-1);
- console.log(delay+ ' more msec...');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement