Skip to content

Instantly share code, notes, and snippets.

@kcranley1
Created September 9, 2015 16:42
Show Gist options
  • Save kcranley1/8cc68c3cf099e0194ce4 to your computer and use it in GitHub Desktop.
Save kcranley1/8cc68c3cf099e0194ce4 to your computer and use it in GitHub Desktop.
Python script for the Raspberry Pi Sense Hat which displays an image observed by the RasPiCam on the RGB LED array and also on the Pi's monitor.
import picamera
from picamera import PiCamera
from picamera.array import PiRGBArray
from sense_hat import SenseHat
sense = SenseHat()
camera = picamera.PiCamera()
def preview():
camera.preview_fullscreen= False
camera.preview_window = (170, -120, 860, 950)
camera.video_stabilization = True
camera.start_preview()
preview()
while True:
# preview()
# with PiCamera() as camera:
camera.resolution = (64, 64)
with PiRGBArray(camera, size=(8, 8)) as stream:
camera.capture(stream, format='rgb', resize=(8, 8))
image = stream.array
pixels = [
pixel
for row in image
for pixel in row
]
sense.set_pixels(pixels)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment