Advertisement
Guest User

Untitled

a guest
Sep 4th, 2013
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. require "serialport"
  2.  
  3. #params for serial port
  4. port_str = "/dev/ttyACM0" #may be different for you
  5. baud_rate = 9600
  6. data_bits = 8
  7. stop_bits = 1
  8. parity = SerialPort::NONE
  9.  
  10. sp = SerialPort.new(port_str, baud_rate, data_bits, stop_bits, parity)
  11.  
  12. #just read forever
  13. while true do
  14. while (i = sp.gets.chomp) do # see note 2
  15. puts i
  16. #puts i.class #String
  17. end
  18. end
  19.  
  20. sp.close #see note 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement