Skip to content

Instantly share code, notes, and snippets.

@nebrius
Created February 15, 2016 05:01
Show Gist options
  • Save nebrius/6594fac379a5c39717dc to your computer and use it in GitHub Desktop.
Save nebrius/6594fac379a5c39717dc to your computer and use it in GitHub Desktop.
Code for my light cube prototype. See http://youtube.com/watch?v=G3BYGcS8h2w&feature…
'use strict';
const five = require('johnny-five');
const board = new five.Board();
const hsv = require('hsv2rgb');
board.on('ready', () => {
const led = new five.Led.RGB({
pins: {
red: 9,
green: 10,
blue: 11
},
isAnode: true
});
let hue = 0;
let reverse = false;
setInterval(() => {
if (reverse) {
hue--;
if (hue === 0) {
reverse = false;
}
} else {
hue++;
if (hue === 359) {
reverse = true;
}
}
const color = hsv(hue, 1, 1);
led.color('#' + color.map((channel) => ('00' + channel.toString(16)).slice(-2)).join(''));
}, 30)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment