The_Official_Raspberry_Pi_-_Beginner’s_Book_Vol1,_2018 (1)

(singke) #1

168 THE OFFICIAL RASPBERRY PI BEGINNER'S GUIDE


Pictures in Python
Start a new program in Thonny and save it as Sense HAT Drawing, then type the following –
remembering to use sense_emu (in place of sense_hat) if you’re using the emulator:

from sense_hat import SenseHat
sense = SenseHat()

Remember that you need both these lines your program in order to use the Sense HAT.
Next, type:

sense.clear( 255 , 255 , 255 )

While not looking directly at the Sense HAT’s LEDs, click the Run icon: you should see them
all turn a bright white (Figure 7-13) – which is why you shouldn’t be looking directly at them
when you run your program!

5 Figure 7-13: Don’t look directly at the matrix when it’s lit up in bright white
Free download pdf