Skip to content

Commit 8545a49

Browse files
authored
Merge pull request #10 from kattni/combo-example
Add combo board example.
2 parents 2094d11 + 02d61bf commit 8545a49

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

examples/lis3mdl_lsm6ds_test.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import time
2+
import board
3+
from adafruit_lsm6ds import LSM6DSOX as LSM6DS
4+
5+
# To use LSM6DS33, comment out the previous line
6+
# and uncomment the next line
7+
# from adafruit_lsm6ds import LSM6DS33 as LSM6DS
8+
from adafruit_lis3mdl import LIS3MDL
9+
10+
accel_gyro = LSM6DS(board.I2C())
11+
mag = LIS3MDL(board.I2C())
12+
13+
while True:
14+
acceleration = accel_gyro.acceleration
15+
gyro = accel_gyro.gyro
16+
magnetic = mag.magnetic
17+
print(
18+
"Acceleration: X:{0:7.2f}, Y:{1:7.2f}, Z:{2:7.2f} m/s^2".format(*acceleration)
19+
)
20+
print("Gyro X:{0:7.2f}, Y:{1:7.2f}, Z:{2:7.2f} rad/s".format(*gyro))
21+
print("Magnetic X:{0:7.2f}, Y:{1:7.2f}, Z:{2:7.2f} uT".format(*magnetic))
22+
print("")
23+
time.sleep(0.5)

0 commit comments

Comments
 (0)