Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import serial
- from time import sleep
- ser = serial.Serial("/dev/ttyS2", 115200, timeout = 1)
- def getTFminiData():
- while True:
- count = ser.in_waiting
- if count >= 9:
- recv = ser.read(9)
- ser.reset_input_buffer()
- if recv[0] == 'Y' and recv[1] == 'Y': # 0x59 is 'Y'
- low = int(recv[2].encode('hex'), 16)
- high = int(recv[3].encode('hex'), 16)
- distance = low + high * 256
- print("This is your distance away from the Lidar: ", distance)
- sleep(1)
- getTFminiData()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement