In today's lab, we will be playing with the SenseHAT module more and exploring the different possibilities and projects that we can make.
or
Writing Python scripts for the Sense HAT module to display data and images through the LED matrix
Animate the LED matrix using loops
Integrate different sensors on the Sense HAT
The Sense Hat module is an add-on board that you can attach to the top of your Raspberry Pi. It attaches to the GPIO (General Purpose Input/Output) pins on the Pi.
In order to set the color of a LED on the matrix, you need to call the set_pixel function on the SenseHat object. The set_pixel() takes an x and y value which corresponds to its location on the matrix and the color value that it should be displaying.
sense.set_pixel(x, y, colour)
To animate the display on the matrix, you can use a nested for loop, which is a for loop within another for loop. You can use the inner for loop to add the code for how you want the display the animation.
for i in range(10):
sense.set_pixels(image2)
sleep(.2)
sense.set_pixels(image)
sleep(.2)
for j in range(5):
sense.flip_h()
sleep(.4)