Category Archives: Creative

Indiana Jones Idol Swap party game

My sister in law does epic children’s parties (a couple of years back I had a lot of fun playing Snape and being mean to all the kids who weren’t in Slytherin) and this year I was given a request to build a game for an upcoming Indiana-Jones themed party.

Remember that bit at the very beginning of Raiders of the Lost Ark where Indy has to balance the idol with a bag of sand to avoid the traps going off?

“Can you build a game that does that?”

So I started thinking along the lines of using an Arduino coupled with a weight sensor which triggers an attached Raspberry Pi to play a tune when the idol is balanced, all packaged up inside a suitably rock looking biscuit tin:

I've got a bad feeling about this
I’ve got a bad feeling about this

The idea would be the idol would be swapped, the Arduino would detect the swap, determine if the weight was different and then set off an alarm and rumble motor if it was. If it was the same weight it would play the Indiana Jones music.

The Arduino has lots of analogue pins that can read changes in voltage, and the Pi can take care of the music and sound effects – it would also be possible to  hook it up to a TV to play the appropriate bit of the film, as chasing down seven year olds with a giant boulder / dart traps / snake pits might not go down well with their parents.

Initially I looked at using a load cell sensor similar to what’s found in electronic scales, however I discovered that the resistance generated by these sensors to be really tiny, and it’s not just a simple matter of hooking them up to an Arduino. Note – since I built my initial version Sparkfun have actually brought out a handy load-cell amplifier kit that should make this possible for version 2!

So instead I opted for a much simpler force sensor – these are widely available and their resistance can be easily measured, but they’re also a bit inaccurate. For the purposes of the game and to add a bit of random variability I decided to go with this simpler route.

My arduino circuit is as follows – it includes an LED to indicate if the pressure sensor is detecting the idol properly. The Arduino communicates with the Pi over serial to then trigger the appropriate sound file. I ran out of time to include the rumble motor but it would be quite easy to add one.

Adafruit have a tutorial along with some suitable code which can be used to send the force sensor output to the Raspberry Pi  via serial:

/* FSR testing sketch. 
 
Connect one end of FSR to 5V, the other end to Analog 0.
Then connect one end of a 10K resistor from Analog 0 to ground
Connect LED from pin 11 through a resistor to ground 
 
For more information see www.ladyada.net/learn/sensors/fsr.html */
 
int fsrAnalogPin = 0; // FSR is connected to analog 0
int LEDpin = 11;      // connect Red LED to pin 11 (PWM pin)
int fsrReading;      // the analog reading from the FSR resistor divider
int LEDbrightness;
 
void setup(void) {
  Serial.begin(9600);   // We'll send debugging information via the Serial monitor
  pinMode(LEDpin, OUTPUT);
}
 
void loop(void) {
  fsrReading = analogRead(fsrAnalogPin);
  Serial.print("Analog reading = ");
  Serial.println(fsrReading);
 
  // we'll need to change the range from the analog reading (0-1023) down to the range
  // used by analogWrite (0-255) with map!
  LEDbrightness = map(fsrReading, 0, 1023, 0, 255);
  // LED gets brighter the harder you press
  analogWrite(LEDpin, LEDbrightness);
 
  delay(100);
}

This also lights up an LED to give useful visual feedback – the Pi then just listens on the serial input and triggers the according sound effect.

Assembled the sensor looks like this (the force sensor is under the lid of the coffee tin):

Indiana Jones style trap game
Indy was out so Han stepped in

Inside my ‘Idol’ (which was a papercraft model printed on shiny paper), was a counterweight made from a stack of pennies – this is reasonably heavy and I was able to adjust the sensitivity of the circuit to detect the presence (and absence) of the Idol.

To build the pedestal I used an octagonal quality street plastic box, covered in paper mache and spray-painted with stone effect spray paint. The arduino and pressure sensor were contained inside a metal coffee tin.

On detecting the Idol being removed, the Pi plays the sound sample “It belongs in a museum” from Raiders of the Lost Ark, if the sensor is successfully fooled it plays the Indiana Jones theme!

After a bit of play testing we found that balancing the idol was very hit and miss – although a handy rock nearby seemed to do the job most of the time. Ideally this would use the much more accurate load cell to measure the weight of the idol and compare it to the bag of sand after a button press. I still have all the parts, so I’m just waiting for the next time someone in my family holds an Indiana Jones themed birthday party.

Indiana Jones Idol Swap game
Here it is (running off a USB battery)

Countdown to Christmas with the Arduino advent calendar!

This year, as part of the publicity for their Christmas charity gifts, Concern Worldwide (who I’m lucky enough to work for) commissioned an artist to come up with a design for an advent calendar.

The resulting design by Robert Fiszer is really rather lovely (you can check out the campaign here)- and lends itself rather well to be illuminated as a Christmas decoration for the Concern office.

Concern Advent Calendar designed by Robert Fiszer
Concern Advent Calendar designed by Robert Fiszer

So as a spare tinkering time project I thought I would have a go at building an Arduino controlled LED advent calendar that illuminates the relevant day and counts down to the 24th.

My requirements needed it to be powered by USB, and that it’s a standalone project with it’s own date clock – as the office IT department would frown upon me installing things on my work PC to run Christmas decorations from. In order to do this I needed to read up on using a battery backed up RTC (Real Time Clock) and a way to control 24 LEDs from my arduino micro.

I decided on using a shift register – the other option would be to use a chain of NeoPixel LEDs, but I wanted to learn about shift registers and get an idea about how they worked. For an excellent introduction to shift registers check out this blog from Bildr.

Essentially a shift register is a way of converting a serial signal from the arduino into a parallel series of high and low signals to the output pins on each chip. Each shift register has 16 pins, 8 output pins, 2 earth pins, 2 positive 5 volt pins, 3 serial input pins consisting of clock, latch and time signals, and a final serial output pin which is used when daisy chaining them together.

The 74HC595 8-bit Shift Register I used was available cheaply on ebay and looks like this:

My diagram of a shift register
There are better diagrams out there but this helped me

Wired up with an arduino on breadboard it looks like this:

Teaching myself about shift registers and Larson scanners #arduino #kitt #cylon

A video posted by Pete Taylor (@kimondouk) on

Even with just 8 outputs it looks a bit messy. With 3 shift registers daisy chained together it looks even more complicated:

Now with 3 shift registers and 24leds #arduino #adventcalendar

A video posted by Pete Taylor (@kimondouk) on

But remember the diagram above – the circuit is still fairly simple, what makes it look complicated is the loops of wire which are all the same length. The challenge I found with the chip is that one of the outputs is on one side, with the remaining 7 on the other.

To tidy everything up, I soldered the chips in carriers onto a piece of full sized Adafruit perma-proto breadboard. I highly recommend using this stuff – it costs a bit more than the generic soldering boards you can buy on ebay, but it’s strong and laid out sensibly using the same layout as standard prototyping boards. In my layout I spaced the shift registers 1 hole apart and moved the offside output around the corner of the chip, so that all 8 outputs were on the same side. To connect my LEDs I was able to add 8 socket female headers as I found soldering the LED wires directly into the board was difficult as the stranded copper wire would snap easily. Plus using headers gives me the option to swap out the LEDs for something else in the future. For LEDs I found pre-soldered 5 volt LEDs available on ebay that included the resistor.

My board includes 4 shift registers giving me a total of 32 outputs – this would enable me to re-purpose the board in future, as I’m thinking after advent it would make a nice monthly calendar.

Here’s the board without any of the LEDs attached:

Shift register without the LEDs
Shift register without the LEDs

For the time circuit I used a DS 1307 RTC – the one I used shares the same chipset as the Adafruit one detailed here (link) (normally I’d buy the adafruit one to support their website, but I couldn’t find it available online).

The code:

/*
Shift register calendar
*/

// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#include <Wire.h>
#include "RTClib.h"

#if defined(ARDUINO_ARCH_SAMD)  // for Zero, output on USB Serial console, remove line below if using programming port to program the Zero!
   #define Serial SerialUSB
#endif

RTC_DS1307 rtc;

// shift register setup

//**************************************************************//
//  Name    : shiftOutCode, Dual One By One                           //
//  Author  : Carlyn Maw, Tom Igoe                               //
//  Date    : 25 Oct, 2006                                       //
//  Version : 1.0                                                //
//  Notes   : Code for using a 74HC595 Shift Register            //
//          : to count from 0 to 255                             //
//**************************************************************//


int SER_Pin = 4;   //pin 14 on the 75HC595
int RCLK_Pin = 5;  //pin 12 on the 75HC595
int SRCLK_Pin = 6; //pin 11 on the 75HC595

int caldate = 0;

//How many of the shift registers - change this
#define number_of_74hc595s 4

//do not touch
#define numOfRegisterPins number_of_74hc595s * 8

boolean registers[numOfRegisterPins];

void setup() 
{
  pinMode(SER_Pin, OUTPUT);
  pinMode(RCLK_Pin, OUTPUT);
  pinMode(SRCLK_Pin, OUTPUT);


  //reset all register pins
  clearRegisters();
  writeRegisters();

#ifndef ESP8266
  while (!Serial); // for Leonardo/Micro/Zero
#endif

Serial.begin(57600);
  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  }

  if (! rtc.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
   rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    // This line sets the RTC with an explicit date & time, for example to set
    // January 6, 2014 at 3am you would call:
    //   rtc.adjust(DateTime(2014, 1, 6, 3, 0, 0));
  }
}

//set all register pins to LOW
void clearRegisters(){
  for(int i = numOfRegisterPins - 1; i >=  0; i--){
     registers[i] = LOW;
  }
  writeRegisters();
} 


//Set and display registers
//Only call AFTER all values are set how you would like (slow otherwise)

void writeRegisters(){

  digitalWrite(RCLK_Pin, LOW);

  for(int i = numOfRegisterPins - 1; i >=  0; i--){
    digitalWrite(SRCLK_Pin, LOW);

    int val = registers[i];

    digitalWrite(SER_Pin, val);
    digitalWrite(SRCLK_Pin, HIGH);

  }
  digitalWrite(RCLK_Pin, HIGH);

}

//set an individual pin HIGH or LOW
void setRegisterPin(int index, int value){
  registers[index] = value;
}


void loop() 
{
  DateTime now = rtc.now();
  caldate = now.day();
  Serial.print(caldate);
   Serial.print(now.day(), DEC);
 
  delay(1500);
  clearRegisters();
  delay(500);

  for (int i = 0; i < caldate; i++)
  {
   setRegisterPin(i, HIGH);
   writeRegisters();
  delay(100);
  }
}

Note – the RTC was the trickiest part of the circuit, and after reading lots of posts from people who’ve had issues with the DS1307 I’d recommend using one of the integrated chip varieties.

The code for the calendar is fairly simple – it checks the date from the RTC and then lights up the appropriate number of lights. I’ve made it loop to give a bit more visual interest, but it’s easy enough to modify the code to make it just light up once when you plug it in.

Assembly

I printed out the calendar image and pasted it onto a bit of board with holes behind each ‘light’. Using a frame from a previous project (the Concern general election Swingometer) to bring it all together. To mount the LEDs I used bottle tops – this involved drinking a lot of diet coke, and when I ran out of that, wine.

Back of the advent calendar
Back of the advent calendar

Here’s the final version, in action as if it’s Christmas Eve showing all the lights as I removed the RTC.

The #arduino shift register powered #adventcalendar is now finished! Happy #1stdecember

A video posted by Pete Taylor (@kimondouk) on

If you liked this project, please buy a gift from Concern’s shop – my personal favourite is the solar lights as they are a neat technological solution to the tricky problem of lighting.

5 geeky DIY Christmas gift ideas

With Christmas rapidly approaching, one of my aims this year is to at least attempt a bit of DIY Christmas gifting. So if you know me, there are potential spoilers ahead and stop reading this right now. So here are five ideas I may or may not be considering as part of my Christmas gift ideas. These really are quite geeky, but then so are most of my friends and family.

1. 3d printed jewellery

We don’t all own 3d printers (yet) particularly ones that can print in precious or semi-precious metals. But head over to Shapeways – a website with a name that sounds like it’s straight from an episode of the Hitch-hikers Guide to the Galaxy and you can print more or less anything you can practically design provided it’s in a format they support. You can also order a printed version of your idea in cheaper plastic before committing to a more expensive material.

For a less daunting project you can contact some of the designers to create customised versions of their work. Lots of designs are available on Thingiverse for you to download and edit (including the ring shape below).

http://www.thingiverse.com/thing:7354
Thingiverse Ring, it’s a thing.

2. Make your own lego brick shaped bath bombs

So slightly less technical but fun nevertheless is to make your own bath bombs or fizzies. These are compacted cubes of Sodium Bicarbonate and Citric Acid that bubble Carbon Dioxide when you chuck them in the bath:

C5H7O5COOH + NaHCO3 → C5H7O5COONa+ + H2O + CO2

Here’s a nice recipe from Busy City Mum’s blog for Bath Fizzies which goes into detail about what quantities and ingredients you need. You can now buy silicon moulds in lots of shapes including Lego brick (lookalikes, not official) and the Death Star (not a moon).

In Japan it’s tradition to include a figure inside the bath bomb, so a Lego minifigure would seem appropriate!

3. A custom Raspberry Pi

A very neat little computer

 

I had to include a Raspberry Pi based project – there are lots to choose from including Media players and retro computer emulators – but for this I wanted to find something that would be suitably difficult to purchase. One possibility is the Raspberry Pi magic mirror which is detailed on it’s creator’s blog – this is something you simply can’t buy, and looks amazing – although you’ll need a monitor and a mirror for the full effect.

My simpler project is to build a Raspberry Pi audio streamer. Audio streamers are generally very expensive and although the Pi’s default audio output is fairly basic it’s possible to add a DAC to provide really high quality sound output. Thanks to Carla at busycitymum.com for sending me a Wolfson Pi I was able to build a fairly decent Pi Music Box with Airport support.

The recipe for this is as follows – I’ve confirmed this to work with the original Wolfson Pi Audio Card and a Raspberry Pi model A – there is a new version of the Wolfson card available for the newer Raspberry Pi models.

  • Download the custom version of Raspbian from www.element14.com/PiAudioCard – on the Mac the custom version of Raspbian unpacks best if you use Stuffit Expander and then Apple Pi Baker to copy the iso file to an SD card.
  • Install Shairport using these instructions from Drew Lustro
  • For a final bit of polish (particularly if your running a Raspberry Pi as a headless server) you can include a web based shutdown control panel – follow the instructions on the forum here. You can edit the web page to include a nice message to your gift recipient as well!
IMG_2679
Raspberry Pi Airport speaker

DIY projects that work with Apple products go down quite well.

4. Bake!

Baking is a much appreciated gift – and given the diversity of cookie cutting shapes available it’s possible to give a nerdy spin on even the most traditional recipes.

Firebox do a nice line in Tetris Cookie cutters – combined with a Gingerbread recipe these make for a pleasing tessellating gift.

I’ve tried a few different gingerbread recipes and Delia’s is by far the best. Thanks to the additional spoon of black treacle the gingerbread is sufficiently biscuity – and you can vary the cooking time if you want a more chewy gingerbread. Other recipes don’t work as well since they opt for either golden syrup or black treacle. Cowards.

Combine with an original Gameboy (search for DMG1) for added wow factor. Works particularly well on millennials.

Gingerbread Tetris
Gingerbread Tetris

5. Give a DIY gift

So technically cheating, but you can also give the gift of DIY. I recently reviewed the StoneTurners DIY microscope

finished USB microscope
I was a little heavy with the glue gun

which can take awesome pictures of things, and works with the Raspberry Pi.

If you want to spend a bit more the DIY projects from Technology will save us are worth a look.  Although they’re more expensive than shopping around and buying the parts, the packaging is lovely and they make quite complicated projects accessible. Plus angry birds on the Arduino is very addictive…