Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time, sys, signal
- import VL53L1X
- tof0 = VL53L1X.VL53L1X(i2c_bus=1, i2c_address=0x29)
- tof1 = VL53L1X.VL53L1X(i2c_bus=1, i2c_address=0x31)
- tof2 = VL53L1X.VL53L1X(i2c_bus=1, i2c_address=0x32)
- tof0.open()
- tof1.open()
- tof2.open()
- tof0.start_ranging(1)
- tof1.start_ranging(1)
- tof2.start_ranging(1)
- running = True
- # gracefully quit
- def exit_handler(signal, frame):
- global running
- running = False
- tof0.stop_ranging()
- tof1.stop_ranging()
- tof2.stop_ranging()
- sys.exit(0)
- # catch SIGINT
- signal.signal(signal.SIGINT, exit_handler)
- while running:
- a = tof0.get_distance()
- b = tof1.get_distance()
- c = tof2.get_distance()
- print("A: {} mm \nB: {} mm\nC: {} mm \n".format(a,b,c))
- time.sleep(0.1)
Advertisement
Add Comment
Please, Sign In to add comment