from sense_hat import SenseHat sense = SenseHat() gyro = sense.get_gyroscope_raw() print("X: {0}, Y: {1}, Z: {2}".format(gyro['x'], gyro['y'], gyro['z']))
from sense_hat import SenseHat sense = SenseHat() while True: gyro = sense.get_gyroscope_raw() print("X: {0}, Y: {1}, Z: {2}".format(gyro['x'], gyro['y'], gyro['z'])) time.sleep(0.1)This code is similar to the first example, but instead of printing the gyroscope data once, it continuously prints the data to the console in a loop using the `while` statement. The `time.sleep()` statement is used to pause the loop for 0.1 seconds between each iteration. The `SenseHat` package library is used in both examples.