Simple test¶
Ensure your device works with this simple test.
1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
2# SPDX-License-Identifier: MIT
3
4import time
5import board
6from adafruit_msa3xx import MSA301
7
8i2c = board.I2C() # uses board.SCL and board.SDA
9# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
10msa = MSA301(i2c)
11
12while True:
13 print("%f %f %f" % msa.acceleration)
14 time.sleep(0.5)
Tap test¶
Check out the tap capability with this example.
1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
2# SPDX-License-Identifier: MIT
3
4import time
5import board
6from adafruit_msa3xx import MSA301
7
8i2c = board.I2C() # uses board.SCL and board.SDA
9# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
10msa = MSA301(i2c)
11
12msa.enable_tap_detection()
13
14while True:
15 if msa.tapped:
16 print("Single Tap!")
17 time.sleep(0.01)