The Astro Pi is equipped with a camera for Earth observation and an LED matrix for status updates. In this lesson, we will learn how to control both.
We need to create a visual countdown sequence before capturing an image. This alerts the crew (or indicates status) before an operation begins.
Objective: Create a synchronized countdown on the LEDs and take a photo.
Instructions:
for loop that counts down from 3 to 1.sense.show_letter() to display the current number.is_cloudy(image_path) that checks if an image has too many white pixels.Controls the LED matrix and reads environmental sensors.
| Usage | Description |
|---|---|
| sense = SenseHat() | Initialize the Sense HAT. |
| sense.clear(r, g, b) | Sets the entire LED matrix to a specific color (0-255). |
| sense.set_pixel(x, y, r, g, b) | Sets a single pixel at (x, y) to a color. |
| sense.show_letter(string) | Scrolls a single character on the matrix. |
Controls the Raspberry Pi Camera Module.
| Usage | Description |
|---|---|
| cam = Camera() | Initialize the camera. |
| cam.take_photo(filename) | Captures an image and saves it to the specified file. |
Standard Python library for time-related functions.
| Usage | Description |
|---|---|
| time.sleep(seconds) | Pauses execution for the specified number of seconds. |