Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var neopixelWrite = require('ESP8266').neopixelWrite;
- var count = 60;
- var pixels = new Uint8Array(count * 3);
- function update() {
- neopixelWrite(14, pixels);
- }
- function rgb(p, r, g, b) {
- var i = p * 3;
- pixels[i] = g >>> 1;
- pixels[++i] = r >>> 1;
- pixels[++i] = b >>> 1;
- }
- function hue(x, h) {
- h = h % 360;
- if (h < 120) return rgb(p, h, 119-h, 0);
- if (h < 240) return rgb(p, 239-h,0,h-120);
- return rgb(p, 0, h-240, 359-h);
- }
- var h = 0;
- var p = 0;
- setInterval(function () {
- print(p, h);
- hue(p, h);
- p = (p + 1) % count;
- h = (h + 13) % 360;
- update();
- }, 33);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement