Accelerometer

The StudioBot includes an accelerometer that can be used to detect movement.

The following example will write out the current acceleration. What value do you think Z would be when the StudioBot is sitting still on the desk?

import time
import board
from StudioBot import *



while True:
    x, y, z = imu.acceleration
    print(x, y, z)
    time.sleep(0.1)

The StudioBot can Shakes:

import time
import board
from StudioBot import *

while True:
    if imu.shake(shake_threshold=15):
        print("Shaken!")
    time.sleep(0.1)

We can detect Taps on the board:

To read more about this accelerometer and CircuitPython, have a read of this Adafruit article.

Last updated