Advertisement
Narayan

serialWrite.py

Oct 5th, 2022 (edited)
638
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 1 0
  1. import serial
  2.  
  3. ser = serial.Serial(
  4.         port = "/dev/ttyUSB0",
  5.         baudrate = 115200,
  6.         timeout = 10,
  7.         xonxoff = False
  8. )
  9.  
  10. val = 0
  11. command = ''
  12. command = input("Enter command: ")
  13. command += str('\n')
  14. val = ser.write(command.encode(encoding = 'ascii', errors = 'strict'))
  15. print('Byres written: ', val)
  16.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement