element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Blog A second helping of Pumpkin Pi
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
GPIO Pinout
Raspberry Pi Wishlist
Comparison Chart
Quiz
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: fustini
  • Date Created: 25 Oct 2012 6:44 AM Date Created
  • Views 4638 views
  • Likes 1 like
  • Comments 20 comments
Related
Recommended
  • halloween
  • pumpkin_pi
  • raspberry_pi
  • rpiexpert
  • adafruit

A second helping of Pumpkin Pi

fustini
fustini
25 Oct 2012
imageWant to build this project?
View Parts

 

In my last post, I introduced the Pumpkin Pi: a Raspberry Pi project for Halloween.  It puts a Raspberry Pi inside a jack-o'-latern to provide web-controlled lights and sound:

image

(click to enlarge; screenshot of latest version as of 2012-Oct-26)

 

The Pumpkin Pi software was written in Python with generous assistance from Bonnie King and can be found on GitHub under my account "pdp7" in the punkin_pi repository.

 

 

Install dependencies:

To run punkin_pi on your Rasperry Pi, you'll first need to install these dependencies.  The following commands were run on the current Raspbian 2012-Sept-18 image:

sudo apt-get update

 

sudo apt-get install git-core mplayer python-setuptools


sudo easy_install bottle

 

sudo easy_install RPi.GPIO

If running an earlier image, then you may encounter an error on when installing the RPi.GPIO in that last step ("couldn't find Python.h").  To resolve the error, run this command:  sudo apt-get install python-dev and then sudo easy_install RPi.GPIO again.  Thanks to Joel Dunn for the advice!

 

 

Install sound clips:

Next, sounds clips that the pumpkin will play need to be installed.  I downloaded a few .wav files from a site with a nice collection of Halloween sound clips and placed in /home/pi/files as punkin_pi expects:

pi@raspberrypi ~ $ mkdir files

 

pi@raspberrypi ~ $ cd files

 

pi@raspberrypi ~/files $ wget http://www.countessbloodshalloweenhorror.com/sounds/howl.wav

 

pi@raspberrypi ~/files $ wget http://www.countessbloodshalloweenhorror.com/sounds/scream.wav

 

pi@raspberrypi ~/files $ wget http://www.countessbloodshalloweenhorror.com/sounds/ghostgigl.wav

 

Any files that mplayer can play can be put into /home/pi/files such as .wav, .mp3 & .ogg.

 

 

Install & run punkin_pi:

Next, I installed the punkin_pi software project via git:

pi@raspberrypi ~ $ git clone https://github.com/pdp7/punkin_pi.git

 

The web server (built on the bottle framework) can be started via:

pi@raspberrypi ~ $ cd punkin_pi


pi@raspberrypi ~/punkin_pi $ sudo python ./control.py

 

It will be available at the Pi's IP address on port 8081.  Here is a video of the web interface in action:

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

(The LEDs happen to be connected to the Raspberry Pi via the Adafruit Pi Cobbler in this video clip as my Adafruit Pi Plate featured in my previous post wasn't handy at the time)

 

 

Audio troubleshooting:

If you want to check if punkin_pi will be able to play a particular file in /home/pi/files, then try to play it with mplayer:

mplayer /home/pi/files/howl.wav

Sometimes the sound system may become unstable and produce errors. Restarting ALSA should resolve this:

sudo /etc/init.d/alsa-utils restart

If your speakers lack a volume control, then the ALSA mixer can be used to adjust volume:

alsamixer

 

 

Cheers,

Drew

 

 

element14
Product Name*DescriptionBuy All Parts
Raspberry Pi Model B with SD Card Raspberry Pi model B and 8GB SD Card with NOOBS preinstalled
Optical mouse Basic USB optical mouse
Keyboard Basic USB keyboard
Adafruit Pi Plate Breakout and expansion board for Raspberry Pi
Tiny Breadboard Small breadboard sized to fit Pi Plate
Adafruit Pi Box Clear acrylic enclosure for Raspberry Pi
(2) NPN BJT NPN bipolar transistor
(2) 1k ohm resistor 1k ohm, 250mW carbon film resistor
(4) Red LED 5mm red LED
(4) 220 ohm resistor 220 ohm, 250mW carbon film resistor
(4) 180 ohm resistor 180 ohm, 250mW carbon film resistor
(4) Yellow LED 5mm yellow LED
20AWG Red Hook Up Wire 20AWG solid copper hook up wire - red
20AWG White Hook Up Wire 20AWG solid copper hook up wire – white
Additional Parts
Product Name*Description
Rechargeable USB Battery Pack4000 mAh Li-Ion battery pack with USB outputs and included cables
Mini SpeakerSmall rechargeable mono speaker with integrated amplifier

 

*Products and resources listed are listed to help members build their own Pi Projects. They are suggestions and listed for educational purposes. For substitutions of any parts, please post a question asking the original author.
  • Sign in to reply

Top Comments

  • Former Member
    Former Member over 13 years ago +2
    I am running an August 2012 Raspbian image. When I went to install the software for this, I found that when I got to the step to install "RPi.GPIO" the compile failed (couldn't find Python.h). I'm not…
  • fustini
    fustini over 13 years ago in reply to Former Member +1
    Thanks for the tip! I'll add it to the instructions above and to the readme in the github repository.
  • Former Member
    Former Member over 13 years ago +1
    Well, my soldering skills are suspect ;-), and I've not been able to blink a light yet. Guess the two us need to put our Pi's in the same pumpkin...I have sound and no lights, and you have lights and no…
  • fustini
    fustini over 13 years ago in reply to fustini

    I think typically PWM would be used to vary the intensity of the LED.  When PWM duty cycle changes randomly, it gives flicker effect.  The Pi's only hardware PWM pin is used by the analog audio, so software PWM is the only option.  Gordon Henderson has written a C library called WiringPi which offers software PWM: https://projects.drogon.net/software-pwm-on-the-raspberry-pi/.  Gordon has a nice halloween raspberry pi project using WiringPi: https://projects.drogon.net/halloween-pi/

     

    This is a software PWM library in Python: https://github.com/aboudou/pizypwm.  It looks promising and was used for a project by its author: https://goddess-gate.com/dc2/index.php/pages/raspiledmeter.en.  I'd like to see if it will play nicely with the bottle framework in punkin_pi.  I think blinken.py would be the most likely place to integrate it.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Former Member
    Former Member over 13 years ago in reply to fustini

    Drew,

     

    Yeah, what I'm gonna do is go back to basics (what I should have done in the first place!) and try it with a breadboard and/or a DMM.  I ordered one of the little breadboards from Adafruit like in the picture in your example, should be here soon.  I may miss Halloween, but I'll have it ready by Thanksgiving ;-)

     

    Thanks for the encouragement and link to the Adafruit tutorial.  Probably should'a started there first, but your project ID got me interested in actually doing something with the GPIO, so that's good!

     

    -Joel

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • fustini
    fustini over 13 years ago in reply to Former Member

    Flicker effect is a great idea.  I'd be very interested to see your results and feel free to send me a pull request on github if you'd like any changes to be pulled into my repo.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Former Member
    Former Member over 13 years ago

    I'll experiment with the different audio files and amixer later.  I want to look a the code now to see if the blinking and duration can easily be randomized, to resemble more of a candle flicker, and maye even break it up ino four sets of lights.

    Next year, we will have one that also blinks with the sound too.

    Regardless, this was a great start. Thanks again!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • fustini
    fustini over 13 years ago in reply to Former Member

    re: the pop - yeah, I get that too and didn't find any way to eliminate it yet. If I remember right, then I think there was less of a pop for mp3 files than wav files.  I'm thinking it might be something to do with the immaturity of the sound driver.  It doesn't occur on my x86 Linux desktop. 

     

    Good to know that it plays analog audio when HDMI isn't connected.  I think it should be possible to switch the audio output with amixer.  From the eLinux wiki:

     

    http://elinux.org/R-Pi_Troubleshooting#Sound_does_not_work_at_all.2C_or_in_some_applications

    sudo amixer cset numid=3 <n>

    where n is 0=auto, 1=headphones, 2=hdmi.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
<>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube