Created
November 28, 2011 02:03
-
-
Save lennonjesus/1398781 to your computer and use it in GitHub Desktop.
Arduino - Enviando e recebendo dados com ruby
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
# 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