Multi-paradigm: procedural from gpiozero import LED, Button led = LED(17) button = Button(4) while True: if button.is_pressed: led.on() else: led.off()
pigpio - remote GPIO from Pi or PC from gpiozero import LED from gpiozero.pins.pigpiod import PiGPIOPin led = LED(PiGPIOPin(22, host='192.168.0.2')) led.blink()
Picamera ● 8 megapixels (v2) – v1 was 5mpx ● Visible light & infra-red versions available ● 1080p30, 720p60 and VGA90 video ● Command line interface and Python library
Picamera - capture from picamera import PiCamera from time import sleep camera = PiCamera() camera.start_preview() sleep(3) camera.capture('/home/pi/Desktop/image.jpg') camera.stop_preview()
Picamera – record video from picamera import PiCamera from time import sleep camera = PiCamera() camera.start_preview() camera.start_recording('/home/pi/video.h264') sleep(10) camera.stop_recording() camera.stop_preview()
Picamera image effects from picamera import PiCamera from time import sleep camera = PiCamera() camera.start_preview() for effect in camera.IMAGE_EFFECTS: camera.image_effect = effect camera.annotate_text = "Effect: %s" % effect sleep(5) camera.stop_preview()
Sense HAT workshop ● Special made for Tim Peake's Astro Pi mission ● Sensors, LED display & joystick ● Great for science, games and creativity ● Works on any Pi model ● Emulators also available
Random sparkles! from sense_hat import SenseHat from random import randint from time import sleep sense = SenseHat() while True: x = randint(0, 7) y = randint(0, 7) r = randint(0, 255) g = randint(0, 255) b = randint(0, 255) sense.set_pixel(x, y, r, g, b) sleep(0.01)