Skip to content

Instantly share code, notes, and snippets.

@stefania11
Created August 27, 2015 11:54
Show Gist options
  • Save stefania11/6a3c83e6190d0ed4363c to your computer and use it in GitHub Desktop.
Save stefania11/6a3c83e6190d0ed4363c to your computer and use it in GitHub Desktop.
require "serialport"
#params for serial port
port_str = "/dev/cu.usbmodem1411" #may be different for you
baud_rate = 9600
data_bits = 8
stop_bits = 1
parity = SerialPort::NONE
serial_port = SerialPort.new(port_str, baud_rate, data_bits, stop_bits, parity)
#just read forever
while true do
while (i = serial_port.gets.chomp) do
puts i
sleep 0.5
end
end
serial_port.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment