Sense Hat Comes Alive

Remember the Raspberry Pi Sense Hat? Originally designed for a mission to the International Space Station, the board has quite a few sensors onboard as well as an 8×8 RGB LED matrix. What can you do with an 8×8 screen? You might be surprised if you use [Ethan’s] Python Sense Hat animation library. You can get the full visual effect in the video below.

The code uses an array to represent the screen, which isn’t a big deal since there are only 64 elements. Turning on a particular element to animate, say, a pong puck, isn’t hard with or without the library. Here’s some code to do it with the library:

for x in range(0,7):
 ect.cell(image,[0,x],[randint(0,255), randint(0,255), randint(0,255)],0.1)
 ect.cell(image,[0,x],e,0.1)
for x in range(7,0, -1):
 ect.cell(image,[0,x],[randint(0,255), randint(0,255), randint(0,255)],0.1)
 ect.cell(image,[0,x],e,0.1)

Each loop draws a box with a random color and then erases it before going to the next position. The second for loop makes the puck move in the opposite direction. You can probably deduce that the first argument is the screen array, the second is the position. The third argument sets the color, and the final argument sets an animation timer. Looking at the code, though, it does look like the timer blocks which is probably not going to work for some applications.

If that’s all there was, this wouldn’t be worth too much, but you can also draw triangles, circles, and squares. For example:

ect.circle(image,(4,4), 3, [randint(0,255), randint(0,255), randint(0,255)], 0.1)

We covered the Sense Hat awhile back. Of course, it does a lot more than just light up LEDs as you can see from this weather dashboard.

11 thoughts on “Sense Hat Comes Alive

  1. “Remember the Raspberry Pi Sense Hat? Originally designed for a mission to the International Space Station, the board has quite a few sensors onboard as well as an 8×8 RGB LED matrix.”

    No i do not, please elaborate.
    To me it sounds a bit hoax-y, why would they allow DIY grade electronics on the ISS, that doesn’t sound right, at all.

      1. “We…”. “WE…”? I assume you are under the mistaken impression that the use of the ‘Papal “WE”‘ lends credibility to your statement. It does not.
        @Oliver–congratulations; the ‘sense hat’ was a very forgettable use of a very forgettable processor. It was designed as nothing more than a grand-standing use of the RPi, much as are most ‘applications” of the rpi machine.

        1. Oh look, another Pi hater here to tell us all how we “are doing it wrong!”, luckily for us we are about to be saved! Oh joy!…

          It exists, people like it and use it. Get over it already!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s