From 02d61bf92b866e35b06878f3ad0fe0f8b7e988f4 Mon Sep 17 00:00:00 2001 From: Kattni Rembor Date: Wed, 17 Jun 2020 12:33:34 -0400 Subject: [PATCH] Add combo board example. --- examples/lis3mdl_lsm6ds_test.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 examples/lis3mdl_lsm6ds_test.py diff --git a/examples/lis3mdl_lsm6ds_test.py b/examples/lis3mdl_lsm6ds_test.py new file mode 100644 index 0000000..cff345e --- /dev/null +++ b/examples/lis3mdl_lsm6ds_test.py @@ -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)