|
16 | 16 | # declare the digital output pins connected to the "SHDN" pin on each VL53L0X sensor
|
17 | 17 | xshut = [
|
18 | 18 | DigitalInOut(board.D7),
|
19 |
| - DigitalInOut(board.D9) |
20 |
| - # add more sensors by defining their SHDN pins here |
| 19 | + DigitalInOut(board.D9), |
| 20 | + # add more VL53L0X sensors by defining their SHDN pins here |
21 | 21 | ]
|
22 | 22 |
|
23 | 23 | for power_pin in xshut:
|
|
33 | 33 |
|
34 | 34 | # now change the addresses of the VL53L0X sensors
|
35 | 35 | for i, power_pin in enumerate(xshut):
|
36 |
| - # turn on the sensor to allow hardware check |
| 36 | + # turn on the VL53L0X to allow hardware check |
37 | 37 | power_pin.value = True
|
38 |
| - # instantiate the VL53L0X sensors on the I2C bus & insert it into the "vl53" list |
39 |
| - vl53.insert(i, VL53L0X(i2c)) # also performs hardware check |
40 |
| - # don't need to change the address of the last VL53L0X sensor |
| 38 | + # instantiate the VL53L0X sensor on the I2C bus & insert it into the "vl53" list |
| 39 | + vl53.insert(i, VL53L0X(i2c)) # also performs VL53L0X hardware check |
| 40 | + # no need to change the address of the last VL53L0X sensor |
41 | 41 | if i < len(xshut) - 1:
|
42 | 42 | # default address is 0x29. Change that to something else
|
43 | 43 | vl53[i].set_address(i + 0x30) # address assigned should NOT be already in use
|
|
46 | 46 | # According to this list 0x30-0x34 are available, although the list may be incomplete.
|
47 | 47 | # In the python REPR, you can scan for all I2C devices that are attached and detirmine
|
48 | 48 | # their addresses using:
|
49 |
| -# >>> import busio |
50 |
| -# >>> i2c = busio.I2C(board.SCL, board.SDA) |
51 |
| -# >>> if i2c.try_lock(): # i2c.scan() requires a lock on the I2C bus |
| 49 | +# >>> import board |
| 50 | +# >>> i2c = board.I2C() |
| 51 | +# >>> if i2c.try_lock(): |
52 | 52 | # >>> [hex(x) for x in i2c.scan()]
|
53 |
| -# >>> i2c.unlock() # free up the bus for something else to use it |
| 53 | +# >>> i2c.unlock() |
54 | 54 |
|
55 | 55 | def detect_range(count=5):
|
56 | 56 | """ take count=5 samples """
|
|
0 commit comments