Skip to content

Instantly share code, notes, and snippets.

@davidwkeith
Created February 6, 2016 21:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidwkeith/3c2654cd0e3bb00afec8 to your computer and use it in GitHub Desktop.
Save davidwkeith/3c2654cd0e3bb00afec8 to your computer and use it in GitHub Desktop.
Flickering candle effect for Halloween
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
@davidwkeith
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment