I was recently given a Raspberry Pi and had the idea to create a neat desk toy which could connect to the internet and look up inspiring and educational famous quotes. But when I found I could just as easily have it generate one-liners, I decided that would be more fun to build a joke machine.

The joke service I’m using is and the jokes can be real groaners. The one partially displayed on this page is a joke attributed to Dean Martin: “You’re not drunk if you can lie on the floor without holding on.”

What follows are the details on how you can make your own Internet Connected Raspberry Pi Powered Joke Machine. Once it’s finished, just press the push-buttons and the machine finds one-liners and scrolls through them. I hope you enjoy this project and possibly learn something as well.

In addition to the parts and tools, you’ll want to grab a copy of the code

This project was one of the many excellent entries in our recent Raspberry Pi project contest

Project Steps

Setting up and installing a new Raspberry Pi

The Pi arrives with no operating system installed. An easy way to decide which flavor of Linux you want on your Raspberry Pi is to use a NOOBS SD card. NOOBS stands for New Out of the Box Software . You can buy a pre-installed NOOBS SD card (what I used for this project) or download your own from

First connect an HDMI cable, power adapter and USB keyboard (no ethernet is needed for NOOBS).

When NOOBS boots up, you’ll be presented options to install any of several LInux “flavors”:

  • Archlinux – a configurable linux distro not recommended for newbies
  • OpenELEC – Open Embedded Linux Entertainment Center (OpenELEC) a small Linux distribution meant to be a media Center
  • Pidora – Pidora is a Fedora Remix optimized for the Raspberry Pi computer
  • RaspBMC – the XBOX Media Center interface
  • Raspbian (recommended) Raspbian is a free operating system based on Debian optimized for the Raspberry Pi hardware
  • RiscOS – RISC OS is a British operating system designed specifically for the ARM processor

I picked the recommended Raspbian flavor of Linux

Change from the default password of pi / raspberry

Enable ssh from the advanced options (more about SSH later).

Next, run the startx command to bring up the graphical desktop.

Connecting the the PiFace Control and Display LCD

The PiFace Control and Display LCD screen is a shield that is meant to easily fit onto the Raspberry Pi. It comes with some example code that we need. You can install this code by running the following command.

sudo apt-get install python{,3}-pifacecad

Then test it out by running the program:

python3 /usr/share/doc/python3-pifacecad/examples/

Installing and configuring a WiPi wireless dongle

sudo nano /etc/network/interfaces

Fill in your router id and password on the following lines:

wpa-ssid "ssid"

wpa-psk "password"

Reboot your system:

sudo reboot

After the reboot, the Pi will connect to your network and you’ll be able to surf the internet or just sit back and enjoy the nice blue glow the WiPi gives off when it is communicating.

Optional - How to access your Pi without need for a keyboard or Display using VNC remote access.

Host Setup –your Pi:

In order to free up your HDMI monitor, why not set up VNC so you can access your Pi from a normal laptop or desktop computer? VNC is a tool that includes the vncserver process which provides graphical applications without connecting any screen to the Pi itself. You simply connect with vncviewer.

Install vncserver by running this command on the Pi:

sudo apt-get install tightvncserver

Start the VNC server by running the command (Note, the first time you run it it will ask you to create a vnc password, remember it you’ll need it later)


Client Setup –your laptop or desktop:

Download vncviewer for your laptop (or desktop) computer.

Connect from your laptop using the IP address and port of the vncserver (and the password you created above)

Now you can use VNC even when you don’t have a monitor for the Pi, you can either set it up so vncserver starts automatically at boot time (as described later), or connect to the pi by using ssh or winscp, then log on command-line style and start the server.

Installing my provided python script,

The joke machine software – — is written in Python, which comes pre-installed on NOOBs.

Download my script from to your Raspberry Pi and copy file to /home/pi/bin

Make it executable by running the command

chmod +x /home/pi/bin/

Install the “PiFace Control And Display” Example code. The PiFace Control and Display LCD screen comes with some example code we need.

Install it by running the following command:

sudo apt-get install python{,3}-pifacecad uses Pycurl to call off to the web and get a random quote. To install pycurl run the following command:

sudo apt-get install python-pycurl

At this point you can run: /home/pi/bin/

It will connect to the free service and display hilarious one-liners. It does this by getting a one-liner back in straight text, splitting it up into 16-Char wide segments and then allowing you to scroll up and down through those segments using the PiFace buttons:

The Joke Machine Buttons:

  • Button 1 is “Back”
  • Button 2 is “Advance Display”
  • Button 3 is “New Quote”
  • Button 4 is “Quit”

Install Your Joke Machine in a Project Box -

The steps here vary depending on the box you select, but basically:

Use a Sharpie to mark where the LCD display should be mounted on the project box lid.

Use a tin snips to cut slots in the edge of the project box to make room for the buttons and the power adapter cord.

Use a Dremel style tool to cut a hole in the lid of the box (and to smooth out sharp edges).

Finally a little tape will really cover any remaining sharp edges. A label machine can be used to label the machine (is that redundant or ironic?).

Quotes Instead of Jokes

If you’d like to get Famous Quotes or Chinese Fortunes instead of One-Liners (there are many varieties available on , make two simple changes to

Change the “source” used on this line:

c.setopt(c.URL, '')

Replace the source name with this line

lineout = re.sub(r'[oneliners.*','',lineout)

To Run The Joke Machine at startup time

The script can run automatically at startup in several ways, but the following works well download the file “” from calls

Copy it to /etc/init.d

cp ./ /etc/init.d

Make the shell script executable

chmod +x /etc/init.d/

Test run the script to ensure it won’t have problems at reboot time.


Once you’re certain the code runs as expected, register the command to run at startup:

sudo update-rc.d defaults