Created
February 15, 2016 05:01
-
-
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…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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