Advertisement
Guest User

Untitled

a guest
Aug 12th, 2022
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.38 KB | None | 0 0
  1. # Write your code here :-)
  2. # Write your code here :-)
  3. # https://github.com/adafruit/Adafruit_CircuitPython_VL53L1X/blob/main/adafruit_vl53l1x.py
  4. # https://github.com/adafruit/Adafruit_CircuitPython_BusDevice/blob/main/adafruit_bus_device/i2c_device.py
  5. import time
  6. import board
  7. import busio
  8. import digitalio
  9.  
  10.  
  11. fault = False
  12. I2CP = None
  13.  
  14.  
  15. if not fault:
  16.     sensors = {
  17.         'down': {
  18.             'pin': None,  # Remember this one will always be active so we set it first to get it off the default.
  19.             'address': 0x27
  20.         },
  21.         'up':{
  22.             'pin': board.D0,
  23.             'address': 0x2b
  24.         },
  25.         'left': {
  26.             'pin': board.D1,
  27.             'address': 0x2d
  28.         },
  29.         'right': {
  30.             'pin': board.D2,
  31.             'address': 0x2f
  32.         },
  33.         'front': {
  34.             'pin': board.D3,
  35.             'address': 0x31
  36.         },
  37.         'back': {
  38.             'pin': board.D6,
  39.             'address': 0x33
  40.         }
  41.     }
  42.  
  43.     try:
  44.         for sensor in sensors:  # Configure pins and set them low.
  45.             pin = sensors[sensor]['pin']
  46.             if pin is not None:
  47.                 pin = digitalio.DigitalInOut(pin)
  48.                 pin.switch_to_output(value=False)
  49.                 sensors[sensor]['pin'] = pin
  50.     except Exception as err:
  51.         fault = True
  52.         print(err)
  53.  
  54. print('success')
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement