Are there any guides for how to interact with the LED and IMU on the XIAO BLE Sense using CircuitPython? I’ve seen a few different installation blog posts but couldn’t find anything “official”
This worked for me, you might need to add some noise filters but it should get you going.
import board
import time
import digitalio
import busio
from adafruit_lsm6ds.lsm6ds3 import LSM6DS3
class IMU(LSM6DS3):
def init(self):
dpwr = digitalio.DigitalInOut(board.IMU_PWR)
dpwr.direction = digitalio.Direction.OUTPUT
dpwr.value = 1
time.sleep(1)
i2c = busio.I2C(board.IMU_SCL, board.IMU_SDA)
super().init(i2c)
if name == “main”:
imu = IMU()
while True:
print(“Acceleration: X:%.2f, Y: %.2f, Z: %.2f m/s^2” % (imu.acceleration))
print(“Gyro X:%.2f, Y: %.2f, Z: %.2f radians/s” % (imu.gyro))
print("")
time.sleep(0.5)
To use the LED:
import digitalio
import time
led = digitalio.DigitalInOut(board.LED)
led.direction = digitalio.Direction.OUTPUT
while True:
# Blink LED to indicate the script is running
led.value = not led.value
time.sleep(2.0)