Mark2020H

Pyton serial port and arduino dot matrix

Mar 31st, 2021 (edited)
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. #!/usr/bin/env python2.7
  2. #MD Harrington  For  Bryan  Cairns  Void realms  re MySQL  and serial port interaction #
  3. # Following code is  fine  with arduino dot matrix display  on its own #
  4.  
  5.  
  6. import serial
  7. import syslog
  8. import time
  9.  
  10. #The following line is for serial over GPIO
  11. port='/dev/ttyACM0'
  12. baudrate=57600
  13.  
  14.  
  15. ser = serial.Serial(port,baudrate,timeout=5)
  16.  
  17. with open('mytext.txt') as fp:
  18.     lines = fp.readlines()
  19.     for line in lines:
  20.         m_array = line.encode('ascii')
  21.         time.sleep(6)
  22.         ser.write(m_array)
  23. #Serial read section
  24.         msg = ser.readline()
  25.         print ("Message from arduino: ")
  26.         print (msg)
  27.     else:
  28.         print "Exiting"
  29. ser.close()
  30. exit()
  31.  
Add Comment
Please, Sign In to add comment