How to Show a Message on a SenseHat

by BenN73 in Circuits > Raspberry Pi

5205 Views, 1 Favorites, 0 Comments

How to Show a Message on a SenseHat

FD5HSN1IT68BD54.LARGE.jpg

Hello, today I will be showing you how to display a message on a Raspberry Pi SenseHat.

Hook Up the Raspberry Pi

sensehat.jpg

Before we do any coding on the Raspberry Pi, we need to connect the right wires to it. Plug an HDMI cable into the HDMI port, plug in the power, and connect a keyboard and a mouse to it. If you want, you can connect an ethernet cable to it if you want to connect to the Internet. Connect it to a monitor, and voila! You can access the Raspberry Pi.

Open Up Python 3 (IDLE)

snek.png
256.png

In the top left corner of your screen, you should see a geometric raspberry icon. Click on that, and some options will come up. You should see "Programming". Click on that, and then click on "Python 3 (IDLE). A window should pop up called "Python 3.5.3 Shell

Import SenseHat to Python

raspberry pie.jpg
led display.jpg

At the top left of the window, type (exactly as read):

from sense_hat import SenseHat

If you did it right, the"from" and "import" should be orange. Press enter, and type:

sense = SenseHat()

Make sure you use the parentheses. They signify a command.

Display the Message

maxresdefault.jpg

Press enter twice, then type:

sense.show_message("Your message here")

That should be it! Your message should be showing on the display!

Optional Effects

2000px-AdditiveColor.svg.png

If you want to get extra fancy, you can change the speed, text color, and background color of the message.

To change the text speed, enter the command like this:

sense.show_message("your message here", text_speed=random#)

1 is the default speed.

To change the color of your text or background, you need to set RGB variables first. RGB variables are colors, and you set them like this:

r = (255, 0, 0)

The first number is red value, the second green, and the third blue. After setting variables, enter the command like this:

sense.show_message("your message here", text_colour=variable, back_colour=variable)

You can combine any of these commands to change up your message.