Skip to content

Commit 032056d

Browse files
committed
Update code.py
1 parent b4ed28d commit 032056d

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

LED_Bullwhip/code.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,16 @@
2020
import audiobusio
2121
import board
2222
import neopixel
23-
import adafruit_lsm6ds
23+
24+
i2c = board.I2C() # uses board.SCL and board.SDA
25+
26+
# check for LSM6DS33 or LSM6DS3TR-C
27+
try:
28+
from adafruit_lsm6ds.lsm6ds33 import LSM6DS33 as LSM6DS
29+
sensor = LSM6DS(i2c)
30+
except RuntimeError:
31+
from adafruit_lsm6ds.lsm6ds3 import LSM6DS3 as LSM6DS
32+
sensor = LSM6DS(i2c)
2433

2534
# CUSTOMISE COLORS HERE:
2635
COLOR = (40, 3, 0) # Default idle is blood orange
@@ -70,12 +79,7 @@
7079

7180
WAVE_FILE = None
7281

73-
i2c = board.I2C() # uses board.SCL and board.SDA
74-
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
75-
76-
#Set up accelerometer & mic
77-
78-
sensor = adafruit_lsm6ds.LSM6DS33(i2c)
82+
#Set up mic
7983
mic = audiobusio.PDMIn(board.MICROPHONE_CLOCK,
8084
board.MICROPHONE_DATA,
8185
sample_rate=16000,

0 commit comments

Comments
 (0)