The_Official_Raspberry_Pi_-_Beginner’s_Book_Vol1,_2018 (1)

(singke) #1
Chapter 7 Physical Computing with the Sense HAT 159

THE OFFICIAL RASPBERRY PI BEGINNER’S GUIDE


Finally, click on the down arrow next to ‘background off’ to see the same list of colours
again. This time, though, choosing a colour doesn’t affect the LEDs that make up the message
but the LEDs that don’t – known as the background. Choose blue from the list, then click the
green flag again: this time your message will be in a bright yellow on a blue background. Try
changing these colours to find your favourite combination – not all colours work well together!
As well as being able to scroll entire messages, you can show individual letters. Drag your
scroll message block off the script area to delete it, then drag a show letter A block onto the
script area in its place. Click the green flag, and you’ll see the difference: this block shows only
one letter at a time, and the letter stays on the Sense HAT until you tell it otherwise without
scrolling or disappearing. The same colour controls apply to this block as the scroll message
block: try changing the letter’s colour to red (Figure 7-6).


5 Figure 7-6: Displaying a single letter


CHALLENGE: REPEAT THE MESSAGE
Can you use your knowledge of loops to have a scrolling
message repeat itself? Can you make a program that spells
out a word letter-by-letter using different colours?
Free download pdf