Created
September 1, 2012 21:07
-
-
Save letsbreelhere/3587353 to your computer and use it in GitHub Desktop.
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 'rubygems' | |
require 'sinatra' | |
require 'serialport' | |
port_str = "/dev/tty.usbmodemfa131" | |
baud_rate = 9600 | |
data_bits = 8 | |
stop_bits = 1 | |
parity = SerialPort::NONE | |
set sp: SerialPort.new(port_str, baud_rate, data_bits, stop_bits, parity) | |
post '/' do | |
settings.sp.putc("a\r\n") | |
'Success!' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The only set up is probably changing port_str to the name of the USB device on your box. The rest of the params are pretty standard (and the baud rate of 9600 is specified in the Arduino part as well), and the only writing going on in this case is the
#putc
method. Also, Arduino seems to only read a string once it gets a CRLF (\r\n
).