Skip to content

Instantly share code, notes, and snippets.

@ma2shita
Created May 7, 2016 14:42
Show Gist options
  • Save ma2shita/e28bf897e4f9d333f5fd12a0c2b0c560 to your computer and use it in GitHub Desktop.
Save ma2shita/e28bf897e4f9d333f5fd12a0c2b0c560 to your computer and use it in GitHub Desktop.
Example code using patlite.rb
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