I've been blogging about my experience in Road Test reviewing the Ultimate Raspberry Pi Bundle. As a part of this Road Test I'm creating a Fridge/Freezer Temperature Alarm system for our local food shelf, Channel 1. You can see where this Road Test started for me here

 

Here is a short video of a project I created as a way of learning the Raspberry Pi. The Joke Machine queries iheartquotes.com and displays a One-Liner in 16 char segments. It uses the momentary buttons found on the PiFace Control and Display to allow you to scroll forward and backward the joke and request a new joke.

 


To create the Joke Machine I had to do the following:

I found a website that provides free Quotes (including One-Liners which is what I used here). The quotes come back in basic text and so I figured a simply wget or curl example would work....I ended up using pycurl and not using python3. Seemed like I was having problems getting the pifacecad examples to both be using the same version fo Python. In fact many examples of using the buttons on the PiFaceCad required python3...which is fine, but I was running into problems getting pycurl to run in python3. So I ended up using the following style of handling multiple buttons on the PiFace https://gist.github.com/larsks/6161684

Install the PiFace Control And Display Example code

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

 

Install PyCurl

sudo aptitude install python-pycurl

 

Install TheQuoteMachine.py

This is the python script I created to query www.iheartquotes.com to get the one-liner, break it into 16 char segments and handle the buttons to allow users to scroll.
I posted the code for TheQuoteMachine.Py as an attachment in my previous blog post
PiFace Control & Display - The Ultimate Raspberry Pi Bundle

Don't forget to make it executable by running chmod +x /home/pi/bin/TheQuoteMachine.py

 

Push a Button, Get a Joke

Now you can run /home/pi/TheQuoteMachine.py  It will connect to the free service http://www.iheartquotes.com and display hilarious one-liners. It does this by getting the 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 Quote Machine Buttons:

  • Button 1 is the back button
  • Button 2 is the advance display button
  • Button 3 is the New Quote button
  • Button 4 is the Quit Button