SHARE
TWEET

Untitled

a guest Sep 15th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import serial
  2. import time
  3. import sys
  4. import os
  5.  
  6. def main():
  7.     s = serial.Serial("/dev/ttyUSB0", 9600) // the second serial should be capitalized
  8.     while 1:
  9.         s.write("lon1\n".encode()) // Need .encode() on each of them
  10.         time.sleep(1) // time.sleep is in seconds, not milliseconds so it should be 1
  11.         s.write("lof1\n".encode())
  12.         s.write("lon2\n".encode())
  13.         time.sleep(1)
  14.         s.write("lof2\n".encode())
  15.         s.write("lon3\n".encode())
  16.         time.sleep(1)
  17.         s.write("lof3\n".encode())
  18.  
  19. if __name__ == '__main__':
  20.     try:
  21.         main()
  22.     except KeyboardInterrupt:
  23.         print ("Interrupted")
  24.         try:
  25.             sys.exit(0)
  26.         except SystemExit:
  27.             os._exit(0)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top