Last active
June 4, 2016 07:43
-
-
Save ikaruga777/ee808fd8708a5871eca7916556627c94 to your computer and use it in GitHub Desktop.
hue
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
| #hueのライトをいい感じに点滅させながらSense 2007を再生するプログラム | |
| require 'hue' | |
| #mp3再生するコマンド | |
| Sense_2007 = 'afplay Sense2007.mp3' | |
| begin | |
| pid = spawn(Sense_2007+'&' , in: "/dev/null", out:"/dev/null", err: "/dev/null") | |
| puts pid | |
| hue = Hue::Client.new | |
| loop do | |
| 1.upto 16 do |i| | |
| # つける | |
| hue.lights.each_with_index do |light,n| | |
| state = {:on => true, :hue => ((i*4000*(1+n)) % 65535), :saturation => 255, :brightness => 255 } | |
| p light.set_state state, 1 | |
| end | |
| # けす | |
| hue.lights.each do |light| | |
| state = {:on => false} | |
| p light.set_state state, 1 | |
| end | |
| sleep 0.3 | |
| end | |
| end | |
| # Ctrl+Cの捕捉 | |
| rescue Interrupt | |
| puts "end." | |
| kill = "pkill -f #{Sense_2007}" | |
| system kill | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment