We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1283ea4 commit cf1c955Copy full SHA for cf1c955
Magic_Nine_Ball/magic_nine_ball.py
@@ -24,7 +24,7 @@
24
# Set up accelerometer on I2C bus, 4G range:
25
I2C = busio.I2C(board.SCL, board.SDA)
26
27
-ACCEL = adafruit_lis3dh.LIS3DH_I2C(I2C, address=0x18) # Production board
+ACCEL = adafruit_lis3dh.LIS3DH_I2C(I2C, address=0x18)
28
29
ACCEL.range = adafruit_lis3dh.RANGE_4_G
30
@@ -51,8 +51,10 @@
51
52
# Wait forever
53
while not shaken:
54
- ACCEL_X, ACCEL_Y, ACCEL_Z = ACCEL.acceleration # Read the accel-z
55
- time.sleep(0.001)
+ try:
+ ACCEL_X, ACCEL_Y, ACCEL_Z = ACCEL.acceleration # Read the accelerometer
56
+ except IOError:
57
+ pass
58
# print(ACCEL_Z) # uncomment to see the accelerometer z reading
59
if ACCEL_Z > 5:
60
shaken = True
0 commit comments