Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Andrea Torlai
Created August 8, 2024

Astrial - Using the Sense Hat

The goal of this tutorial is to show how to use the Raspberry Pi Sense Hat with the Astrial board by System Electronics

89
Astrial - Using the Sense Hat

Things used in this project

Story

Read more

Schematics

Schematic

Code

sense_hat_example.py

Python
from sense_hat_astrial import SenseHat

# Create an instance of the SenseHat class
sense = SenseHat()

# Display a message on the LED matrix
sense.show_message("Hello World")

joystick_example.py

Python
from sense_hat_astrial.stick import SenseStick
from sense_hat_astrial import SenseHat

# Create an instance of the SenseHat class
sense = SenseHat()
# Create an instance of the SenseStick class
stick = SenseStick()

# Define a callback function
def callback(event):
    if (event.action == "pressed" or event.action == "held"):
        # Display the direction on the LED matrix
        sense.show_letter(str(event.direction[0]).upper())
    else:
        sense.clear()

stick.direction_any = callback

input("Press Enter to exit...")

imu_example.py

Python
from sense_hat_astrial import SenseHat
import time

# Create an instance of the SenseHat class
sense = SenseHat()

# Get the orientation, temperature, and humidity
while True:
    orientation = sense.get_orientation_degrees()
    print("Orientation:", orientation)

    temperature = sense.get_temperature()
    print("Temperature:", temperature)
    
    humidity = sense.get_humidity()
    print("Humidity:", humidity)

    pressure = sense.get_pressure()
    print("Pressure:", pressure)
    
    time.sleep(0.2)

Credits

Andrea Torlai

Andrea Torlai

11 projects • 3 followers

Comments