|
1 | 1 | import time |
2 | 2 | import board |
3 | | -import digitalio |
4 | 3 | import busio |
5 | 4 | import adafruit_lis3dh |
6 | 5 |
|
7 | 6 | # Hardware I2C setup. Use the CircuitPlayground built-in accelerometer if available; |
8 | 7 | # otherwise check I2C pins. |
9 | 8 | if hasattr(board, "ACCELEROMETER_SCL"): |
10 | 9 | i2c = busio.I2C(board.ACCELEROMETER_SCL, board.ACCELEROMETER_SDA) |
11 | | - int1 = digitalio.DigitalInOut(board.ACCELEROMETER_INTERRUPT) |
12 | | - lis3dh = adafruit_lis3dh.LIS3DH_I2C(i2c, address=0x19, int1=int1) |
| 10 | + lis3dh = adafruit_lis3dh.LIS3DH_I2C(i2c, address=0x19) |
13 | 11 | else: |
14 | 12 | i2c = busio.I2C(board.SCL, board.SDA) |
15 | | - int1 = digitalio.DigitalInOut(board.D6) # Set to correct pin for interrupt! |
16 | | - lis3dh = adafruit_lis3dh.LIS3DH_I2C(i2c, int1=int1) |
| 13 | + lis3dh = adafruit_lis3dh.LIS3DH_I2C(i2c) |
17 | 14 |
|
18 | 15 | # Hardware SPI setup: |
19 | 16 | # spi = busio.SPI(board.SCK, board.MOSI, board.MISO) |
20 | 17 | # cs = digitalio.DigitalInOut(board.D5) # Set to correct CS pin! |
21 | | -# int1 = digitalio.DigitalInOut(board.D6) # Set to correct pin for interrupt! |
22 | | -# lis3dh = adafruit_lis3dh.LIS3DH_SPI(spi, cs, int1=int1) |
| 18 | +# lis3dh = adafruit_lis3dh.LIS3DH_SPI(spi, cs) |
23 | 19 |
|
24 | 20 | # PyGamer or MatrixPortal I2C Setup: |
25 | 21 | # i2c = busio.I2C(board.SCL, board.SDA) |
26 | | -# int1 = digitalio.DigitalInOut(board.ACCELEROMETER_INTERRUPT) |
27 | | -# lis3dh = adafruit_lis3dh.LIS3DH_I2C(i2c, address=0x19, int1=int1) |
| 22 | +# lis3dh = adafruit_lis3dh.LIS3DH_I2C(i2c, address=0x19) |
28 | 23 |
|
29 | 24 |
|
30 | 25 | # Set range of accelerometer (can be RANGE_2_G, RANGE_4_G, RANGE_8_G or RANGE_16_G). |
|
0 commit comments