File tree 2 files changed +16
-16
lines changed
2 files changed +16
-16
lines changed Original file line number Diff line number Diff line change 9
9
10
10
# Uncomment _one_ of the hardware setups below depending on your wiring:
11
11
12
- # Hardware I2C setup:
12
+ # Hardware I2C setup. Use the CircuitPlayground built-in accelerometer if available;
13
+ # otherwise check I2C pins.
13
14
import busio
14
- i2c = busio .I2C (board .SCL , board .SDA )
15
- lis3dh = adafruit_lis3dh .LIS3DH_I2C (i2c )
16
-
17
- # Hardware I2C setup on CircuitPlayground Express:
18
- # import busio
19
- # i2c = busio.I2C(board.ACCELEROMETER_SCL, board.ACCELEROMETER_SDA)
20
- # lis3dh = adafruit_lis3dh.LIS3DH_I2C(i2c, address=0x19)
15
+ if hasattr (board , 'ACCELEROMETER_SCL' ):
16
+ i2c = busio .I2C (board .ACCELEROMETER_SCL , board .ACCELEROMETER_SDA )
17
+ lis3dh = adafruit_lis3dh .LIS3DH_I2C (i2c , address = 0x19 )
18
+ else :
19
+ i2c = busio .I2C (board .SCL , board .SDA )
20
+ lis3dh = adafruit_lis3dh .LIS3DH_I2C (i2c )
21
21
22
22
# Software I2C setup:
23
23
#import bitbangio
Original file line number Diff line number Diff line change 8
8
9
9
# Uncomment _one_ of the hardware setups below depending on your wiring:
10
10
11
- # Hardware I2C setup:
11
+ # Hardware I2C setup. Use the CircuitPlayground built-in accelerometer if available;
12
+ # otherwise check I2C pins.
12
13
import busio
13
- i2c = busio .I2C (board .SCL , board .SDA )
14
- lis3dh = adafruit_lis3dh .LIS3DH_I2C (i2c , address = 0x19 )
15
-
16
- # Hardware I2C setup on CircuitPlayground Express:
17
- # import busio
18
- # i2c = busio.I2C(board.ACCELEROMETER_SCL, board.ACCELEROMETER_SDA)
19
- # lis3dh = adafruit_lis3dh.LIS3DH_I2C(i2c, address=0x19)
14
+ if hasattr (board , 'ACCELEROMETER_SCL' ):
15
+ i2c = busio .I2C (board .ACCELEROMETER_SCL , board .ACCELEROMETER_SDA )
16
+ lis3dh = adafruit_lis3dh .LIS3DH_I2C (i2c , address = 0x19 )
17
+ else :
18
+ i2c = busio .I2C (board .SCL , board .SDA )
19
+ lis3dh = adafruit_lis3dh .LIS3DH_I2C (i2c )
20
20
21
21
# Software I2C setup:
22
22
#import bitbangio
You can’t perform that action at this time.
0 commit comments