For one intensive weekend with professor Matt Richardson, a class of ITP nerds had the chance to get familiarized with the tiny, trendy Raspberri Pi computer and some of it’s applications in making media-making devices.
Raspberry Pi
Raspberry Pi is a small affordable computer (starting at $35) that can do basically anything you tell it to do. It’s highly customizable and it’s official documentation is geared to kids, making it quite easy to learn.
It has an operating system, Raspbian, which delights the user with a somewhat familiar desktop interface. To begin using it you’ll need to load on a microSD card from your everyday computer in a process that will format the card. When you do it, be careful to not format your own hard drive by accident.
Raspberry Pi 4 has 2 HDMI display ports allowing 4K displays, 4 USB ports that can be used for mouse and keyboard interface, as well as anything else you can think of. It has an ethernet connection port as well as bluetooth and wi-fi connection capabilities. The wi-fi connection is tricky and requires registration of each specific Raspberry Pi device on the network. In addition, Raspberry Pi has plenty of digital pins allowing you to connect any physical computing component compatible with 3.3V logic. This makes Raspberry Pi into an ideal computer for jamming with screen interfaces and physical interfaces such as sensors, motors and light sources – all combined.
Example #1: photo booth
The first media-making device we’ve attempted to create is a simple photo booth involving a Picamera, a bedazzled push button and a series of colorful LEDs.
Clicking the push button activated a 3 second delay sequence until the camera takes the image. The colorful LEDs and a “DING” sound indicate the count-down.
The JPEG picture was saved on the Raspberry Pi desktop with the suffix indicating the date and time when it was taken (image07_10_03_58_40.jpg), just like we coded it to: imageName = “image” + strftime(“%m_%d_%H_%M_%S”, gmtime()) + “.jpg”
This is the code used:
from picamera import PiCamera from time import sleep, gmtime, strftime from gpiozero import LED, Button global greenLED global yellowLED global redLED greenLED = LED(18) yellowLED = LED(17) redLED = LED(15) myCamera = PiCamera() cameraButton = Button(14) def takeSelfie(): myCamera.resolution = (1024,768) myCamera.start_preview(alpha=100) greenLED.toggle() sleep(1) greenLED.toggle() yellowLED.toggle() myCamera.start_preview(alpha=150) sleep(1) yellowLED.toggle() redLED.toggle() myCamera.start_preview(alpha=200) sleep(1) imageName = "image" + strftime("%m_%d_%H_%M_%S", gmtime()) + ".jpg" myCamera.capture(imageName) myCamera.stop_preview() redLED.toggle() yellowLED.off() redLED.off() greenLED.off() cameraButton.when_pressed = takeSelfie
Python Programming Language
To run custom-made programs on Raspberri Pi, we needed to write then in Python on the Thonny IDE (integrated development environment).
Fortunately it was not the first programming language I encounter. However it was different than any of them.
Unlike JS, HTML, and CSS that make excessive use of brackets and curly brackets, Python is as bracket-bare as can be. Instead of that, it’s sensitive to precise spacing and indenting. Musing with Python with code-savvy teammates Timothy and Hayk made me understand why it’s considered a more poetic programming language.
Example #2: quick mathematics game
For a second, more sophisticated example, we’ve created a quick mathematics game. The user had limited time to solve random calculus problems. Whether the user solved the problem correctly or not, was rewarded with audio feedback and score system. When the time is up and the game is done, a picture of the winner (or looser!) was automatically captured.
that’s how it looked like:
And this is the code used:
from guizero import App, Text, TextBox from gpiozero import Button from picamera import PiCamera import time import random import pygame pygame.init() cheer = pygame.mixer.Sound("/home/pi/cheer.wav") submitButton = Button(14) app = App(title="Quik Mafs") time = 60 score = 0 operations = ["multiply", "add", "subtract"] correctAnswer = 0 scoreText = Text(app, "Score: 0", size = 20) timerText = Text(app, "10", size = 10) firstNumText = Text(app, "1") operationText = Text(app, "plus") secondNumText = Text(app, "1") myCamera = PiCamera() finished = False answerBox = TextBox(app, text = "") def counter(): if (timerText.value != "0"): timerText.value = int(timerText.value)-1 else: global finished if (finished == False) : myCamera.start_preview(alpha=100) myCamera.capture("finished.jpg") cheer.play() myCamera.stop_preview() finished = True def generateEq(): firstNum = random.randint(1,10) firstNumText.value = str(firstNum) secondNum = random.randint(1,10) secondNumText.value = str(secondNum) operation = operations[random.randint(0,2)] global correctAnswer if (operation == operations[0]): operationText.value = "*" correctAnswer = firstNum * secondNum elif (operation == operations[1]): operationText.value = "+" correctAnswer = firstNum + secondNum elif (operation == operations[2]): operationText.value = "-" correctAnswer = firstNum - secondNum def checkEq(): if (timerText.value == "0"): return global score if (str(correctAnswer) == answerBox.value): score += 1 print("Correct") else: score -= 1 print("Incorrect") scoreText.value = "Score: " + str(score) generateEq() answerBox.clear() submitButton.when_pressed = checkEq generateEq() timerText.repeat(1000, counter) app.display()
Applications
Besides learning the basics of Raspberry Pi and coding in Python, we received insight into some contemporary applications of Media-Making Devices:
Amusement Park rides
An inside look shows how wired and automated are amusement parks nowadays, with the visitor’s experience being accompanied and enhanced with a mobile app
Escape Room Back-end interfaces
The technology behind escape rooms is a remarkable example for original, custom-made user interfaces created specifically for one-of-a-kind experiences.
Immersive Environments
We got an inside look into an audio-visual ride launching a brand new Google feature at a Tech convention in Las Vegas. This cutting-edge, technologically-boosted, meticulously-designed experience introduced the new feature by doing the impossible: Making a 92-year old grandma birthday into a thrilling joyride.
Applications as rich and sophisticated as these are some of the most entertaining man-made art available to humans to engage with. As an artist, this technology got me inspired. As a new media professional, I see the deep influential potential it carries. It looks like an immensely exciting, rewarding, technically and conceptually challenging innovative field of expertise. Hopefully I’ll find my own particular ways of leveraging it to move, shake, change opinions, captivate hearts and blow minds.