Data Sheet

Bonus chapter.indd 13 Trim size: 7.375 in × 9.1875 in October 24, 2017 7:20 PM
BC13BONUS CHAPTER 1 QUICK REFERENCE TABLES
Chapter 9
Accessories Command Quick Reference Table
Command Description
From picamera import PiCamera
Imports the picamera modules
camera.start_preview()
camera.stop_preview()
Starts the camera preview
Stops the camera preview
camera.capture(‘/home/pi/Pictures/
image.jpg’)
Captures a jpeg image and stores it in the
Pictures directory
avconv –r 10 –i image%02d.jpg –
qscale 2 timelapse.mp4
Converts a series of images into a movie
using
avconv
import explorerhat
Imports the Explorer HAT module
explorerhat.light.red.on()
explorerhat.light.red.off()
Switches the red LED on the Explorer
HAT on and then off
explorerhat.touch.pressed(button_
pressed)
Posts a message to chat in Minecraft Pi
from sense_hat import SenseHat
sense = SenseHat()
Imports the Sense HAT modules
sense.show_message(“Hello
Sense HAT!”)
Scrolls a test string across the LED matrix
on the Sense HAT
temp = sense.get_temperature()
Gets the current temperature from the
temperature sensor on the Sense HAT
sense.set_pixels(happy)
Sets all the pixels on the LED matrix of
the Sense HAT at the same time
Achievement Unlocked: Experimented with cameras and HATs