from sense_hat import SenseHat sense = SenseHat() heading = sense.get_compass() print("Compass Heading: {}".format(heading))
from sense_hat import SenseHat sense = SenseHat() while True: heading = sense.get_compass() print("Compass Heading: {}".format(heading))In this example, we again import the SenseHat package library and initialize the SenseHat object. We use a while loop to continuously retrieve and print out the current compass heading. The package library used here is called "sense_hat".