Skip to content

Commit

Permalink
Merge pull request #10 from kattni/combo-example
Browse files Browse the repository at this point in the history
Add combo board example.
  • Loading branch information
ladyada committed Jun 17, 2020
2 parents 2094d11 + 02d61bf commit 8545a49
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions examples/lis3mdl_lsm6ds_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import time
import board
from adafruit_lsm6ds import LSM6DSOX as LSM6DS

# To use LSM6DS33, comment out the previous line
# and uncomment the next line
# from adafruit_lsm6ds import LSM6DS33 as LSM6DS
from adafruit_lis3mdl import LIS3MDL

accel_gyro = LSM6DS(board.I2C())
mag = LIS3MDL(board.I2C())

while True:
acceleration = accel_gyro.acceleration
gyro = accel_gyro.gyro
magnetic = mag.magnetic
print(
"Acceleration: X:{0:7.2f}, Y:{1:7.2f}, Z:{2:7.2f} m/s^2".format(*acceleration)
)
print("Gyro X:{0:7.2f}, Y:{1:7.2f}, Z:{2:7.2f} rad/s".format(*gyro))
print("Magnetic X:{0:7.2f}, Y:{1:7.2f}, Z:{2:7.2f} uT".format(*magnetic))
print("")
time.sleep(0.5)

0 comments on commit 8545a49

Please sign in to comment.