Advertisement
silver2row

Trying w/ tfmini from some source online...

May 5th, 2021
739
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. import serial
  2. import time
  3.  
  4. ser = serial.Serial('/dev/ttyS1', 115200, timeout = 1)
  5.  
  6. ser.write(0x42)
  7. ser.write(0x57)
  8. ser.write(0x02)
  9. ser.write(0x00)
  10. ser.write(0x00)
  11. ser.write(0x00)
  12. ser.write(0x01)
  13. ser.write(0x06)
  14.  
  15. while(True):
  16.     while(ser.in_waiting >= 9):
  17.         if(('Y' == ser.read()) and ('Y' == ser.read())):
  18.             Dist_L = ser.read()
  19.             Dist_H = ser.read()
  20.             Dist_Total = (ord(Dist_H) * 256) + (ord(Dist_L))
  21.             for i in range (0,5):
  22.                 ser.read()
  23.         #time.sleep(0.0005)
  24.         print Dist_Total
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement