Created
May 7, 2016 14:42
-
-
Save ma2shita/e28bf897e4f9d333f5fd12a0c2b0c560 to your computer and use it in GitHub Desktop.
Example code using patlite.rb
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 "./patlite" | |
Patlite.host = "192.168.254.209" | |
patlite = [] | |
[:red, :yellow, :green].each do |i| | |
patlite << Patlite.new(i) | |
end | |
loop do | |
a = patlite.sample | |
p "target: #{a.target}" | |
old = a.state? | |
if a.off? | |
a.on | |
else | |
a.off | |
end | |
p "#{old} => #{a.state?}" | |
sleep (3..20).to_a.sample/10.0 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment