Category Archives: Workshop / Lecture / Demo

Raspberry Pi Workshop at Machine Project

Raspberry Pi workshop

I will be teaching a three day Raspberry Pi workshop at Machine Project on Tuesday, July 29th, Thursday, July 31st, and Tuesday, August 5th, 2014. The workshop will focus on using the Raspberry Pi camera module with an emphasis on basic video and audio applications.

In this workshop we will cover getting started with Raspberry Pi computers with an emphasis on working with HD video playback, using the camera module and getting started with sound output using Pure Data. Technically inclined audio-visual artists are encouraged to attend but anyone with a general curiosity about the Raspberry Pi and Linux is welcome. The first class session will focus on getting the Raspberry Pi up and running which will include: installing the system, configuring a WIFI module, and running basic commands

The second class meeting will cover playing back HD video files with a Raspberry Pi and using the camera module to capture HD videos to disk, creating a Python script to make a time-lapse camera capture device, and if time permits we will explore a RaspberryPi “Video Synth” that is remotely controlled from your laptop.

The third class will meeting will delve into using the Raspberry Pi’s built-in audio functions which will include: basic audio playback, installing Pure Data, and running Pure Data patches on a Raspberry pi.

Raspberry Pi – Installing the System

Installing the system on your SD Card

1. Download the system software here: – choose the latest Raspian “Wheezy” installer

Once the file downloads, extract the image by double clicking on the download file and put the image file on your desktop.

2. Insert your SD card into the card reader and see that it mounts on the desktop
3. Open the OS X Disk Utility application from your Utilities folder.
4. Select the SD card partition in the left-hand menu and click on the erase tab.
5. Make sure the format is MS-DOS(FAT) and click on erase to reformat the card.
6. Once the card formats choose ‘verify disk’ and look for the BSD name: must be something like diskn where n is a number (for example, disk4). Note this number.
7. Click Unmount from the menu above.
8. Open the Terminal application from your Utilities folder and run the following:

sudo dd if=path_of_your_image.img of=/dev/diskn bs=1m

Make sure to replace the ‘n’ of ‘diskn’ in the command with the number you noted from the BSD name in the previous step.

here’s what the command looked like on my computer

sudo dd if=/users/dwingus/desktop/2014-01-07-wheezy-raspbian.img of=/dev/disk3 bs=1m

This step copies the Linux system software onto the card. Once you hit return to start the 'dd' command your terminal will look like nothing is happening at all. This is a good thing. Go get some coffee and relax. An eight gigabyte SD card takes around fifteen minutes or so to format properly. Larger SD cards will take longer.

When the card is formatted you will see something like the following on your terminal:
2805+0 records in
2805+0 records out
2962227200 bytes transfered in 1002.34582 secs

You're done!

Drag the icon for your SD card to the trash and remove it from your laptop.

Insert the SD card into the Raspberry Pi and plug it in. Have fun!

Raspberry Pi – Initial Configuration for Video

raspberry pi video configuration

Raspi-Config Menu

When you boot your Raspberry Pi for the first time make sure it is connected to a display. The software configuration window should open. You can run the raspi-config program from the terminal at any time by typing:

sudo raspi-config

In the raspi-config menu navigate to the following options and make changes:

1) Expand the filesystem – will resize the amount of storage space available
2) Change User Password: the default is raspberry. change it to be r
5) Enable camera – yep. gotta turn it on
7) Overclocking — set to High or Turbo
8) Advanced options —
– A2 Hostname – you can change this if you’ll be working with multiple Pis via a command line
– A3 Memory split for gpu – set to 256
– A4 SSH – confirm that the SSH server is on. It should be by default

Click finish and reboot the Pi.

Change the Time Zone

On your Pi’s terminal type:

sudo dpkg-reconfigure tzdata


US, pacific ocean

Software Update
Its a good idea at this point to make sure all of the Pi’s software is up to date. The system version we installed was created in January so some of the libraries and programs have been updated since then. Type the following commands to do a complete software update

sudo apt-get update
sudo apt-get upgrade  

Your Pi is now configured! type the following to reboot

sudo reboot

Raspberry Pi – WIFI Setup

To get a WIFI dongle going I find its easier if you use the Pi’s GUI. To do so make sure the Pi is connected to a video monitor and your WIFI dongle is plugged into a USB port. Start your Pi and login.

– To start the Pi’s GUI type:


– Double click on the WIFI Config icon that is on the desktop. A status window will open.
– Click the Scan button to scan for wireless networks.
– Select the network you’d like to join and double click on its name. Another window will open.
– In the first field labeled SSID make sure that the network name is displayed correctly
– In the PSK field type in the network password
– That is all you need to edit. Click on the Add button on the bottom of the window. Then close the Scan window
– In the main window titled wpa_gui you’ll see the network status. If you successfully joined the network the Status field will say Completed
– Look at the last field titled IP address and make note of the IP address. You’ll need the IP address in order to login to the Pi remotely from your laptop.

Disable WIFI Power Saving

If you find that your wireless connection is spotty and unpredictable try disabling WIFI power saving.Do the following:

– Type

sudo nano /etc/modprobe.d/8192cu.conf

to create a new config file
– Paste the following in to the file:

# Disable power saving
options 8192cu rtw_power_mgnt=0 rtw_enusbss=1 rtw_ips_mode=1

- Save the file
- Type

sudo reboot

to reboot your Pi

The following link provides more information on getting setup on a wired or WIFI network.

Adafruit WIFI Overview

Raspberry Pi – SSH & Remote Login

At some point you probably will want to connect to your Pi remotely using the Terminal program on your laptop. This allows for the Pi to be run “headlessly” – meaning a display is not connected to the Pi.

In order to connect to the Pi from your laptop the Pi will need to be connected to a network and you will need to know the Pi’s IP Address. Type the following command on your Pi:

ip addr

and make note of the IP address. Its the other one, not

Make sure your laptop is connected to the same network as the Pi you’d like to remotely connect to. On your laptop open the Terminal program from the Utilities folder. At the prompt type:

ssh pi@ip-address 

replace ‘ip-address’ with the actual IP address of your Pi

The command looked like this on my laptop:

ssh pi@

Press return, answer ‘yes’ to the authentication question, and enter the Pi’s password

Raspberry Pi – Email IP Address

When running a Pi headlessly it’s helpful to find out the IP address without having to connect the Pi to a display. A Python script can be executed on boot to send you an email that contains the Pi’s IP address. You’ll need to edit the Python script that is linked below and one other file on your Pi to make this happen. You also need to know the Pi’s current IP address.

Download the following python script to your laptop:


Once downloaded, change the name to “”
Open the file in a text editor on your laptop and add information to the following variables:
     to – this is your email address
     gmail user – this is your gmail username
     gmail password – this is your gmail password
Save the file to your desktop

It’s probably pretty obvious but you have to use a Gmail account. In the next step you will upload the python script from your laptop to your Pi.

Upload the script to your Pi using a new ‘local’ terminal window on your laptop
In the Terminal program on your laptop type command-t to open another session window. Make sure you are typing commands to your laptop and not the Pi! Check the command line prompt at this point.
In the new / local terminal window type:

 scp /users/username/desktop/ pi@ip-adress:/home/pi/scripts

make sure to edit the username and ip-address to match your settings. The command, assuming is on the desktop, looked like this on my laptop:

scp /users/dwingus/desktop/ pi@

Back on the Pi’s terminal window (check the prompt) move to your home directory

cd /home/pi

Make the python script executable

sudo chmod +x

Make a new directory called scripts

sudo mkdir scripts

Move the file to the scripts directory

sudo mv scripts

Now the python script is in place and is ready to be executed.

Edit the rc.local file that will call the script when the Pi boots

Open the file rc.local in the nano text editor

sudo nano /etc/rc.local  

Add the following right above “fi”:

python /home/pi/scripts/

Save the file

rc.local is a file that is called at the end of the Pi’s boot sequence. You’ve placed a command in rc.local that calls Python to execute the startup_mailer script that ultimately emails you the Pis IP address.

If you find that you do not receive an email when the Pi boots try a couple of things:
– confirm that you entered all of your email information correctly in the python script

 sudo nano /home/pi/scripts/

- make sure your Pi is connected to the internet

 ip addr

- try running the script directly from Python and then check your email

sudo python /home/pi/scripts/

- If you get an email when running the script directly as in the line above try adding a pause to the rc.local file.
Open the file rc.local in the nano text editor

sudo nano /etc/rc.local  

Add the following right after # Print the IP Address

sleep 5 

This will cause the system to wait 5 seconds before executing the python script. Sometimes the Pis need just a hair more time to establish a network connection.

Raspberry Pi – Keyboard Layout

You may find that certain characters do not show up as expected when typing on a keyboard connected to your Pi. This is because the default keyboard layout is set to work in Great Britain and some of the character mappings are different. To fix this you need to change the keyboard layout to work in the US.

To change the keyboard layout you need to edit a file. Type:

sudo nano /etc/default/keyboard

Change the line:




Save the file and reboot the Pi

sudo reboot

Raspberry Pi – Backing up the SD Card

1. Shutdown the Raspberry Pi:

sudo shutdown -h now

Remove the SD card and insert it into your laptop’s card reader.
2. On your laptop’s local terminal program type:

mkdir ~/Desktop/Pi_BU

to make a folder for the backup image
3. Then type:

df -h

and look for your SD card. Make note of the disk number. It should look something like: /dev/disk3s1
4. Unmount the SD card:

diskutil unmount /dev/disk3s1

(change the 3 to your card’s disk number)
5. Start the backup:

sudo dd if=/dev/rdisk3 of=~/Desktop//pi_BU/wheezy-backup.img bs=1m

Wait about 10 minutes for an 8GB card

Raspberry Pi – Image Viewer

Raspberry Pi Image Viewer

INSTALL AN IMAGE VIEWER ON THE PI – Single view and Slideshow

To install the FBI image viewer type the following in a terminal on your Pi:

sudo apt-get install fbi

To view an image type the following:

sudo fbi -d /dev/fb0 -a -T 2 0001.jpg

#  the -d /dev/fb0 flag calls a 'framebuffer'

#  the -T 2 is needed when controlling the pi via SSH - tells it to use the Terminal for input

To "unview" the image you have to kill the FBI process. To find the FBI process type:

ps -aux | grep fbi

# ps -aux lists all processes running which is then "piped" (|) to the grep search function which looks for any fbi processes

To kill the FBI process type:

sudo kill  [process id number]

To start a slideshow of images in a folder via SSH terminal

sudo fbi -d /dev/fb0 -a -T 2 -t 5 *.jpg

#  the - t  (lowercase) sets the time interval in seconds between images

To start a slideshow of images in a folder without the photo information on the bottom of the screen type:

sudo fbi -noverbose -a -t 10 -T 2 -d /dev/fb0 *.jpg

Raspberry Pi – Gallery Video Player

This tutorial will turn your Raspberry Pi into a simple video player. The Raspberry Pi will automatically begin playing a folder of video files when it starts. The files in the folder will randomly repeat until the script is stopped or the Pi is turned off. To see a demonstration video please go here.The following instructions assume you are logged in to your Pi from a remote computer.

Create a folder and copy video files to your Pi

To create a new folder named videos for your video files type:

mkdir videos

To move into the newly created videos directory type:

cd videos

Open a new “local” terminal window. You’ll run the next command on the “local” terminal and not the terminal window connected to your Pi
To copy a folder of video files from your laptop’s desktop to your Pi type :

scp /Users/[your username]/Desktop/[folder name>]/* pi@[your Pi's ip address]:/home/pi/videos

The command looked like this on my computer:

scp /Users/dwingus/Desktop/vids/* pi@

Type your Pi’s password, press return and wait for videos to transfer. The next step is to create a shell script using the nano text editor.

Shell Script to play videos in a folder

Log in to your Pi. and type:

sudo nano playseries

Copy the following into the Nano text editor:

if [ x"$1" = x"help" -o x"$1" = x"--help" -o x"$1" = x"-help" ];then
echo "Usage: playseries [folder path]"
echo "Audio mode can be either 'hdmi' or 'local'."
echo "Folder path is the full path to folder full of video files."
echo "This script will try to play all files in the video folder regardless of file type"
while true
for file in $2/*
omxplayer -o $1 $file


Save the script file by typing control-x
Make the script executable by typing:

sudo chmod +x playseries

Move the file to the /usr/bin folder by typing:

sudo mv playseries /usr/bin


Running the script

The script follows the format:

[scriptname] [audio-output] [path_to_directory]

To run the script using the HDMI audio out type:

playseries hdmi /home/pi/videos

To run the script using the local audio out type:

playseries local /home/pi/videos

Blanking the Pi's screen between video files

You'll notice when you run the script that OmxPlayer pauses between video files and there is text that is displayed on the video monitor. To eliminate the text you need to basically tell the Pi to make the screen black.
To fix this edit the file here:

sudo nano /etc/kbd/config

In the config file change "BLANK TIME" to a value of 2 and save the file
Then restart your Pi by typing:

sudo reboot

Automatic Login and Running the Script on Boot

To get your Raspberry Pi to automatically login when booted and to call the playseries script complete the following steps:
- Type:

sudo nano /etc/inittab

- Scroll to the line: #1:2345:respawn:/sbin/getty 115299 tty1 and put a # in front of it to comment out the line of code
- Add a new line underneath:

1:2345:respawn:/bin/login -f pi tty1/dev/tty1 2>&1

- Save the file. This will make your Pi automatically login when booted.
- To start the playseries script automatically on boot edit your .bash_profile file by typing:

sudo nano ~/.bash_profile

- Add the following line to the file:

playseries local /home/pi/videos

- Save the file. Commands located in the .bash_profile file will be executed when the Pi boots
- To reboot your pi type

sudo reboot