Advertisement
Guest User

Untitled

a guest
Dec 10th, 2013
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var b = require('bonescript');
  2. var state = b.HIGH;
  3. var delay = 500;
  4. b.pinMode('USR0', 'out');
  5. b.pinMode('USR1', 'out');
  6. b.pinMode('USR2', 'out');
  7. b.pinMode('USR3', 'out');
  8.  
  9. var tab = new Array('USR0', 'USR1', 'USR2', 'USR3');
  10.  
  11. // i is the index to turn on
  12. function led(index)
  13. {
  14. for (i = 0; i < tag.length; i++)
  15. console.log("Setting " + index + " high");
  16. b.digitalWrite(tab[i], (index = i) ? b.HIGH: b.LOW);
  17. }
  18. setTimeout(function(){led((index++) % tab.length);}, delay);
  19. }
  20.  
  21. console.log('Start...');
  22. // turn off all lights with an out of range index, and start the recursive calls
  23. led (-1);
  24. console.log(delay+ ' more msec...');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement