Chapter 7 Physical Computing with the Sense HAT 173
THE OFFICIAL RASPBERRY PI BEGINNER’S GUIDE
Then go to the bottom and type:
while True:
sleep( 1 )
sense.flip_h()
Click Run, and watch the creeper as it closes and opens its eyes, one at a time!
5 Figure 7-17: Showing a simple two-frame animation
The flip_h() function flips an image on the horizontal axis, across; if you want to flip an
image on its vertical axis, replace sense.flip_h() with sense.flip_v() instead. You
can also rotate an image by 0, 90, 180, or 270 degrees using sense.set_rotation(90),
changing the number according to how many degrees you want to rotate the image. Try using
this to have the creeper spin around instead of blinking!
CHALLENGE: NEW DESIGNS
Can you design more pictures and animations? Try getting
some graph or grid paper and using it to plan out your picture
by hand, first, to make writing the variable easier. Can you
draw a picture and have the colours change? Tip: you can
change the variables after you’ve already used them once.