Skip to content

Instantly share code, notes, and snippets.

@yuiseki
Created May 20, 2009 15:17
Show Gist options
  • Save yuiseki/114866 to your computer and use it in GitHub Desktop.
Save yuiseki/114866 to your computer and use it in GitHub Desktop.
rubyでArduinoのシリアルポートを叩く
require 'rubygems'
require 'serialport'
sp = SerialPort.new("COM6", 9600, 8, 1, SerialPort::NONE)
command = ["0D"]
sp.write(command.pack("H*"))
sp.read
sp.read
loop {
light = sp.read
if light.to_i < 100
puts "akarui!!!"
else
puts "kurai..."
end
sleep 10
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment