Last updated
pebble {code}’s latest hack day theme was hardware. It happened to fall on Halloween. So the natural thing to do was to combine Halloween and hardware. So why not put a Raspberry Pi in a pumpkin and make it make some scary sounds?
I was new to working with the GPIO on the Raspberry Pi and after a brief effort to get an analogue sensor working I decided to go back to basics and get an LED flashing. This turned out to be the hardest part of the hack. After briefly failing to compile python and node modules (not enough memory) I began to despair. Thankfully around about this time new employee Jaz Lalli turned up. We found Wiring Pi a GPIO interface written in C.
Taking the example code we knocked up a script to blink the LED
#include <wiringPi.h>
int main (void)
{
wiringPiSetup () ;
pinMode (0, OUTPUT) ;
for (;;)
{
digitalWrite (0, HIGH) ; delay (500) ;
digitalWrite (0, LOW) ; delay (500) ;
}
return 0 ;
}
It didn’t work. We soon realised that the GPIO number was wrong and the pin map we’d be referring to didn’t match the GPIO library. After fixing that we were set and quickly added five more LEDs all blinking in unison.
Toby Hunt stepped up and went to our local supermarket and carved the pumpkin. By this stage we had flashing red lights inside the carved pumpkin.
The initial idea was to use a proximity sensor to trigger a sound whenever anyone walked by the pumpkin. We found some scary sounds and thought we were all set. There was one problem though - we didn’t have a proximity sensor.
Instead we decided to make it possible to tweet at the pumpkin using a hashtag. The pumpkin would read out the tweet.
To listen for tweets was quite straightforward - a node script listened on the api for the hashtag #pumpkinpi. In terms of reading out the sound we first tried Festival to read out the tweets. This was ok but the voice was far too friendly. We needed spookiness.
Jaz discovered this script to convert text to speech via the Google translate api
#!/bin/bash
say() { local IFS=+;/usr/bin/mplayer -ao alsa -really-quiet -noconsolecontrols "http://translate.google.com/translate_tts?tl=en&q=$*"; }
This worked really well but again the voice was too friendly. As far as our research went there is no way to change the voice on this api. After some research we discovered that mplayer can play the audio at half speed with the following flag -speed 0.5
. This was terrifying!
The hack was complete.
Have an update or suggestion for this article? You can edit it here and send me a pull request.
Using HashiCorp Vault with LDAP
How to use HashiCorp Vault to setup an LDAP backed secret store with read-only access for users in groups and read-write access for specific users
Linux and Unix xargs command tutorial with examples
Tutorial on using xargs, a UNIX and Linux command for building and executing command lines from standard input. Examples of cutting by character, byte position, cutting based on delimiter and how to modify the output delimiter.
Copy a file in Go
How to copy a file in Go. The ioutil package does not offer a shorthand way of copying a file. Instead the os package should be used.