Skip to content

Instantly share code, notes, and snippets.

@lennonjesus
Created November 28, 2011 02:03
Show Gist options
  • Save lennonjesus/1398781 to your computer and use it in GitHub Desktop.
Save lennonjesus/1398781 to your computer and use it in GitHub Desktop.
Arduino - Enviando e recebendo dados com ruby
# Lennon Jesus - lennon d.o.t. jesus a.t. gmail d.o.t. com
require "serialport"
port_str = "/dev/ttyACM0"
baud_rate = 9600
data_bits = 8
stop_bits = 1
parity = SerialPort::NONE
sp = SerialPort.new(port_str, baud_rate, data_bits, stop_bits, parity)
index = 15
loop do
sp.putc(index)
puts 'Enviando: %d = %bb' % [ index, index ]
index = (index == 15) ? 0 : (index + 1)
sleep(1)
end
sp.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment