from sense_hat import SenseHat sense = SenseHat() acceleration = sense.get_accelerometer() print("Acceleration (x,y,z):", acceleration)
from sense_hat import SenseHat import time sense = SenseHat() while True: acceleration = sense.get_accelerometer() print("Acceleration (x,y,z):", acceleration) time.sleep(1)This code is similar to the previous example, but it uses a while loop to continuously read the acceleration values and print them on the console every second using the time.sleep(1) function. Package Library: The package library used in this example is "sense_hat", which can be installed using pip command.