Created
February 6, 2016 21:09
-
-
Save davidwkeith/3c2654cd0e3bb00afec8 to your computer and use it in GitHub Desktop.
Flickering candle effect for Halloween
This file contains 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
require 'hue' | |
CANDLE_COLOR_RANGE = [*2000..2200] # Kelvin, 2000K is lowest Hue can do | |
CANDLE_BRIGHTNESS_RANGE = [*20..52] | |
bridge = Hue.application | |
candle = Hue::Bulb.new(bridge, 1) | |
candle.on if candle.off? | |
loop do | |
begin | |
candle.color = Hue::Colors::ColorTemperature.new CANDLE_COLOR_RANGE.sample | |
candle.brightness = CANDLE_BRIGHTNESS_RANGE.sample | |
@delay = (rand * 0.2200) + 0.08 | |
rescue | |
puts 'delaying 2 seconds' | |
@delay = 2 | |
end | |
sleep @delay | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Future development at https://gitlab.com/davidwkeith/flickering-candle