Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. var neopixelWrite = require('ESP8266').neopixelWrite;
  2. var count = 60;
  3. var pixels = new Uint8Array(count * 3);
  4. function update() {
  5. neopixelWrite(14, pixels);
  6. }
  7. function rgb(p, r, g, b) {
  8. var i = p * 3;
  9. pixels[i] = g >>> 1;
  10. pixels[++i] = r >>> 1;
  11. pixels[++i] = b >>> 1;
  12. }
  13. function hue(x, h) {
  14. h = h % 360;
  15. if (h < 120) return rgb(p, h, 119-h, 0);
  16. if (h < 240) return rgb(p, 239-h,0,h-120);
  17. return rgb(p, 0, h-240, 359-h);
  18. }
  19. var h = 0;
  20. var p = 0;
  21. setInterval(function () {
  22. print(p, h);
  23. hue(p, h);
  24. p = (p + 1) % count;
  25. h = (h + 13) % 360;
  26. update();
  27. }, 33);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement