Categories
Arduino Creative Family Gadgets Geekery Raspberry Pi

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)
Categories
Arduino Creative Geekery

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.

Categories
Gadgets Geekery Raspberry Pi

Official Raspberry Pi touch display review

Official Raspberry Pi display
It’s bright

This week saw the launch of the official Raspberry Pi display, so I thought I would write up a quick review to share some of my initial thoughts about the device.

Ever since the first version of the Pi there’s been a DSI connector on the board – and although there have been lots of devices that use either USB or the GPIO pins to provide simple touch screens, this is the first to use this official display connector.

I ordered the Pimoroni version of the display which came with a stand for £58 – consisting of 3 layers of laser cut plastic and a couple of feet to stand the screen on. Although this is much handier than just having the display on it’s own I anticipate a lot of Pi-suppliers out there are working on more more robust tablet style enclosures, as this version still leaves the fragile ribbon connectors exposed, along with the Pi itself. The Pimoroni stand is perfect for using the Pi with it’s display on a desk but I wouldn’t chuck it in a bag and take it outside quite yet.

In usual Pimoroni fashion it’s super easy to slot together the stand. Assembling the display itself is straightforward but perhaps a little trickier. The display has a driver board with 2 ribbon cables, and a further ribbon cable which attaches to the DSI port on the Raspberry Pi. I attached the thicker orange cable first, followed by the smaller one, then screwed the board to the back of the display and finally attached the DSI cable between the board and the Pi. I found it easier when I used a couple of plastic screws from my PiBow case to gently nudge the cable covers back into place after I’d slotted each ribbon in place.

You can opt to power the display via the GPIO (jumper cables are provided) or via a USB – it is a slightly tight fit where the Pimoroni stand supports jut out of the back of the display so you’ll need a USB cable with short plugs.

Note the ribbon cable - writing on the inside
Note the ribbon cable – writing on the inside

First impressions

The display itself has a robust metal backing and is solidly constructed from glass. It has a really high quality feel to it. There’s 10 point multi-touch which is capacitive (and I imagine will have lots of interesting programming type uses). The touch was responsive and quick running the Raspbian desktop. As the display doesn’t use the HDMI or video out ports you can add another HD or video display, and it shares the power supply with the Pi. Using the USB power option leaves the GPIO ports free to add Hats to.

Here’s how the desktop looks on the display:

Raspberry Pi desktop on official display
What a brilliant website!

The display worked fine out of the box but there is an update available for Raspbian which you’ll need to enable touch, and you’ll need a USB keyboard unless you’re booting directly into the desktop. You can install an onscreen keyboard with

sudo apt-get install matchbox-keyboard

and start it with

sudo matchbox-keyboard
Raspberry Pi onscreen keyboard
It’s a diddy onscreen keyboard

To be honest I found this a bit small to practically use. An official Raspbian onscreen keyboard will be coming soon no-doubt but i’ll be sticking with my USB keyboard.

Drawbacks?

The resolution of the display is 800 x 480 (the screenshots above are native) which for some might be a little bit lacking, but given that you can add a full HD display at the same time I don’t regard this as a massive drawback. The Pi foundation had to find a compromise between cost and a full HD display would have been more expensive. Plus I think 4k displays on tiny devices are silly, and if you really want something like that you can pick up an Android tablet for not much more. Generally everything displays fine, although there are a few dialogue boxes where the buttons are off screen:

Dialogue box on Raspberry Pi display
Oops. I’ll hit enter now and hope for the best.

The viewing angle left to right is fine, but up/down was a bit sensitive. Generally though colours and contrast looks good out of the box.

I did notice the low power indicator (the rainbow coloured box) appear when I was using a USB Wifi module – and I’ve been running the Pi off the official power supply.

I was worried that the screen itself is also potentially scratchable (the Pimoroni instructions came with lots of warnings) – as it came with a plastic cover I’ve just left that on for now,  as the capacitive touch works fine with it in place. One drawback of the ribbon arrangement is that the DSI cable loops over where the micro SD card sits, so removing it is a bit fiddly.

TouchPi

This is version 1, and when more robust cases come on the market I think a lot of the initial issues like the positioning of cables and power will be solved, as will the software. Looking at how they’ve arranged the hardware I think it would be easy to design a touch pad case for the Pi (i’m really looking forward to see what rainbow inspired case Pimoroni come up with).

I think the exciting thing about the official display is how it changes the nature of the Pi – it feels like a neat self contained all in one computer. I don’t have to worry about SSH or networking, I can plug in a keyboard and start typing away with a GPIO board sitting in front of it.

Given the Pi’s purpose as an educational computer (rather than a mid-30s-bloke-who-likes-to-tinker machine) the official touch display gives the Pi a commonality with tablets and iPads that I think will appeal to young people – finally here’s an all in one machine that will play minecraft out of the box and hopefully inspire tinkering on a level impossible with any other tablet out there.

Update: I built a stand out of Lego, which handily fits quite neatly and includes space below for a Pimoroni black hack3r hat. Pimoroni has also pointed out the the display is actually upside down – the recent Raspbian update flips it over to improve the viewing angle.

#lego #raspberrypi (with official display) all in one computer stand

A photo posted by Pete Taylor (@kimondouk) on

Categories
Gadgets Geekery Raspberry Pi

Ryanteck Raspberry Pi Serial Debug Clip review

When building projects on the Raspberry Pi that run ‘headless’ I’ve often found it necessary to connect to the Pi to see what’s going on, work out why it’s not working as I expected or to simply shut it down neatly without yanking out the power cable.

There are a few ways to do this – you could carry around a keyboard and monitor, hook them up to the Pi and see what’s what. The extremely useful and sadly getting rarer and more expensive Motorola Lapdock which I reviewed a while back works very well as a portable monitor / keyboard combination.

Or you could connect to the Pi using SSH if you’re both connected to the same network.

The third option is to connect to the Pi using a USB to Serial port converter. These are usually available as USB to TTL Serial Cable with a USB plug on one end and a series of female jumper wires on the other. Adafruit have a good guide on how to use one of these. Ryanteck have recently released a Raspberry Pi USB debug chip which works in the same way as the USB serial cables, but which is easier to connect to the Pi and includes friendly green and red LEDs to indicate data being sent back and forth. I recently backed this on Kickstarter so was able to get one to play with.

For this option you do need to carry round a computer, but as I discovered it works well with my tiny Toshiba Encore windows 8 tablet – and even with an Android mobile phone!

Raspberry Pi USB Serial debug chip
Lego spaceman has removed the important little jumper on the bottom left of the clip

Assembling the chip is very straightforward with the instructions on the Ryanteck website – although it’s worth mentioning that the version of the PCB supplied varies slightly from the images in the guide. The final version of the PCB includes a little jumper clip – this is quite important – with the jumper in place the Debug Clip will power the Raspberry Pi. It’s vital that the Pi is powered from either the clip or it’s micro USB port – the serial link will not work if the Pi is powered from both.

The RPi debug clip lacks any headers or sockets – it’s designed to sit on the Raspberry Pi GPIO pins underneath a hat or add-on board. In practice I found it a tight fit on the Raspberry Pi pins and a loose fit on a spare extension header I had lying around so I’ve used a 40 pin extra tall header – with this it’s possible to use the Rpi Clip with the Pimoroni Coupé style cases and have room to fit additional hats on top:

Debug clip sat on a 40 pin tall header, sat on a Pimoroni Coupé case
Debug clip sat on a 40 pin tall header, sat on a Pimoroni Coupé case

Despite having just one micro usb port it’s possible to use the debug clip on the Toshiba with a Micro USB Host OTG Cable – as there are a lot of very cheap Windows based tablets now available I imagine they all work in the same way.

To get the RPi clip working with the Toshiba Encore I installed the driver from the Microchip website, and then looked up the COM port the USB Serial port was using with the Computer Management window (right click on the Windows 8 start icon). In my case it was COM3. I opened up the Windows Telnet App PuTTY, chose a serial connection on COM3 at 115200 baud, hit enter and voila! – the Raspberry Pi login prompt appeared.

RPi debug clip
I do normally use this with a little keyboard, but it’s still very little.

It’s also possible to use the same cable with an Android mobile phone. I tested it with my bog standard Nexus 5 (which hasn’t been rooted) and a free app called DroidTerm – to connect hook up the Pi with the OTG to USB cable, make sure the header on the RPi debug clip is removed and use the following settings:

Droidterm screenshot
Basic connection options

When you first connect the screen will be blank – just enter the username you normally log in on your pi with (I think everyone uses ‘Pi’) and it will prompt you for your password. It’s a basic app – there’s no cut and paste, but for checking on things it’s fine.

Droid term /cat/proc/cpuinfo
Here’s some Pi info on a mobile!

The Ryanteck Raspberry Pi debug clip is available here for about 7 quid.

 

Categories
Creative Family Geekery Raspberry Pi

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…

Categories
Gadgets Geekery Raspberry Pi

£15 DIY usb microscope from StoneTurners

At the Elephant and Castle Mini Maker Faire this weekend I picked up a £15 microscope kit from the guys at StoneTurners (hello!).

This is a hack kit based on a USB webcam where you remove the lens and reverse it to create a cheap microscope. In the box you get a set of parts including the camera itself, a plastic screw pot, some neoprene material and a few laser cut parts.

Photo of the microscope kit
*small robot not included

Instructions can be found over at StoneTurners along with some inspiring images taken with the scope. It’s an easy build – I did however skip over using the neoprene strips instead opting to hot-glue the webcam module inside the plastic screw-pot, and I had to bend the LEDs slightly to fit them inside the hole at the top. What you end up with is 2 ways to adjust the microscope – you can focus the reversed lens attached to the CCD module, and you can raise and lower the microscope ‘stage’ –  being the outer part of the screw pot.

Here’s how mine ended up:

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

You can use the microscope with Camspinner on the Mac – this worked fine with no problems on my Yosemite iMac.

For the ultimate in budget scientific computing, you can use guvcview and plug the USB microscope directly into a Raspberry Pi. I used a model B+ and it worked fine just plugged directly into the USB port, although the low power warning icon did flash up a few times.

To install guvcview just open the terminal and type:

 sudo apt-get install guvcview

then head over to the desktop with startx – the webcam software will be found under Sound and Video in the main start menu.

I did try installing Cheese, but that was a little bit too much for the Pi.

USB microscope running on Raspberry Pi B+
The pretty pattern is my Imac screen

Finally, here are a few pictures I took just trying out the USB microscope:

an LCD screen:

An LCD screen (not OLED or retina, I can’t afford a new mac just yet)

and the tip of a ballpoint pen:

Ballpoint pen with a USB microscope
A ball-point pen

I haven’t tried anything living yet, but when it’s not dark and raining outside I’ll pop down to the thames and see if I can get a water sample. One interesting project might be to look at determining water quality based on what pond-life appears.

In conclusion it’s a fun kit for £15 and I look forward to seeing what they come up with next. You can buy the kit here.

Categories
Arts Code Gadgets Geekery Raspberry Pi

ASCII camera with the Holga 120d

So now I’ve finished my digital Holga project, one of the things I wanted to do was to get a bit creative with it – so here’s my first attempt at an ASCII art generating camera.

Holga 120d ASCII text image
High contrast images work best.

This uses the ASCII art script written by Steven Kay, please visit his blog to find out more – I’ve modified the original script to use the python picamera library – this helps speed up the image resize. There’s also a timestamp added to the text file which uses the same script I wrote about in my previous Holga post.

If you just want to run Steven Kay’s script you’ll need the python imaging tools – install with

sudo apt-get install python-imaging

Here’s my modified script:

'''
ASCII Art maker
Creates an ascii art image from an arbitrary image
Created on 7 Sep 2009

@author: Steven Kay
'''

import time
import picamera
from PIL import Image
import random
from bisect import bisect

# greyscale.. the following strings represent
# 7 tonal ranges, from lighter to darker.
# for a given pixel tonal level, choose a character
# at random from that range.

greyscale = [
            " ",
            " ",
            ".,-",
            "_ivc=!/|\\~",
            "gjez2]/(YL)t[+T7Vf",
            "mdK4ZGbNDXY5P*Q",
            "W8KMA",
            "#%$"
            ]

# using the bisect class to put luminosity values
# in various ranges.
# these are the luminosity cut-off points for each
# of the 7 tonal levels. At the moment, these are 7 bands
# of even width, but they could be changed to boost
# contrast or change gamma, for example.

zonebounds=[36,72,108,144,180,216,252]


#take photo

with picamera.PiCamera() as camera:
                        camera.capture('image.jpg');

# open image and resize
# experiment with aspect ratios according to font


im=Image.open(r"image.jpg")
im=im.resize((160, 75),Image.BILINEAR)
im=im.convert("L") # convert to mono

# now, work our way over the pixels
# build up str

str=""
for y in range(0,im.size[1]):
    for x in range(0,im.size[0]):
        lum=255-im.getpixel((x,y))
        row=bisect(zonebounds,lum)
        possibles=greyscale[row]
        str=str+possibles[random.randint(0,len(possibles)-1)]
    str=str+"\n"

print str

date_string = time.strftime("%Y-%m-%d-%H:%M:%S")

text_file = open('image' + date_string + '.txt', "w")
text_file.write(str)
text_file.close()

There are lots of settings to tweak – the image above was generated by the script – and bear in mind this is designed to be viewed with black text on a white background. Perhaps I’ll see if I can dig out an old dot matrix printer from somewhere.

For a blog of ‘photos’ updated whenever I take them and am in range of WiFi check out:

http://holga120d.blogspot.co.uk/

This emails the ASCII art in HTML format to blogger whenever I take a photo (and the Pi Holga is in range of the internet).

For more about the Digital Holga check out my previous blog posts on the hardware and building the case.

Categories
Geekery Raspberry Pi

Controlling Lego motors with the Ryanteck Raspberry Pi board

I’ve reviewed a few Raspberry Pi add on boards before, including the PiFace which includes a multitude of inputs and outputs, and the minimalistic LEDborg which has a very bright single multicoloured LED.

The Ryanteck Raspberry Pi Motor Controller Board Kit is a GPIO add on board that allows you to control 2 motors with your Raspberry Pi. Although it’s much simpler than the PiFace it’s cheaper (about £12) and is easy enough to assemble yourself. In fact it makes a nice introduction to soldering, and is an ideal project if you want to take the plunge and have a go at making your own hardware.

With the motor controller board you can build a simple Raspberry Pi based rover – you just need 2 motors driving side by side sets of wheels or tracks. Driving the motors in opposite directions allows you to turn on the spot. The Ryanteck board can control motors up to 12 volts to you could always re-purpose a toy or build your own.

There’s some documentation available here, but I thought I’d share my build guide. If you’ve never soldered before check out the Soldering is Easy guide, and try to buy some leaded cored solder. Lead has (quite rightly) been removed from the solder used in commercial products to prevent it ending up in landfill when electronics are thrown away. However lead-free solder is much harder to work with (it’s fine if you’re a robot) and for hobbyist applications it’s easier to work with the leaded variety. Just make sure you don’t throw your electronics projects away once you’ve finished with them.

Build guide

In the kit are 3 sets of 2 pin headers, 3 sets of blue terminal blocks, a GPIO connector pin header and a chip carrier and controller chip.

Don't panic.
Don’t panic.

 

Holding everything in place when you’re soldering is tricky – so my tip here is to use the GPIO header block to hold the parts in place while you solder them. So first we have the set of 3 2 pin headers:

The spacing is just right!
The spacing is just right!

Next we’ll solder the chip holder into place, using the GPIO header plugged into one of the sets of 2 pin headers – orientate the cut out to the left hand side of the board:

Chip holder next, held in place with the GPIO header
Chip holder next, held in place with the GPIO header

Next comes the blue terminal pins. These are a tighter fit so easier to just rest the board on the blocks and solder away. Finally comes the GPIO header. Remember to solder this facing down – you’ll need something to rest the board on. Fortunately I discovered this was exactly one lego minifigure knee in height, so I used the lego workman as a rest:

Soldering is Awesome!
Soldering is Awesome!

 

Finally comes connecting it all up and testing. The board is rated for a range of motor voltages. Surprisingly as I seem to have a lot of Lego around I thought I’d test it with a vintage Lego technic motor. Lego motors come in different voltages – the very old ones are 4.5v and the newer ones tend to be 9v. My motor is 9 volts but I’m running it off a 5 volt USB power supply, which I’m using in my Lego rover project. The motor runs a bit slower but is fine for my purposes. Attach the power supply for the motor to the J1 blue terminal with positive on the left hand side.

It lives!
It lives!

There’s a test program included in the instructions to switch the motor on, and change it’s direction for a set period of time.

Create the program with:

sudo nano motortest.py

 

copy the following code:

##Simple motor script for the RTK-000-001
import RPi.GPIO as GPIO
import time
#Set to broadcom pin numbers
GPIO.setmode(GPIO.BCM)
#Motor 1 = Pins 17 and 18
#Motor 2 = Pins 22 and 23
GPIO.setup(17, GPIO.OUT)
GPIO.setup(18, GPIO.OUT)
#Now loop forever turning one direction for 5 seconds, then the other
while (True):
#Sleep 1 second then turn 17 on
 GPIO.output(18, 0)
 time.sleep(1)
 GPIO.output(17, 1);
 time.sleep(5);
#And now the other way round
 GPIO.output(17, 0)
 time.sleep(1);
 GPIO.output(18, 1);
 time.sleep(5);
 #And loop back around
#And final cleanup
GPIO.cleanup()

 

and then run it using:

sudo python motortest.py

 

You’ll need to use sudo as you’re using the GPIO pins.

Finally here’s a picture of the almost completed Lego Rover: all that’s to do next is to write some software and add a PiCam:

Curiosity killed the cat..
Curiosity killed the cat..

The Ryanteck Raspberry Pi board is a nice kit, easy to put together and get going straight away, and works with Lego motors so there’s quite a range of interesting things you can try. Ryanteck has now launched a complete robot kit that includes a chasis as well. For more info check out their GitHub project page. It’s a bargain way of making your Pi control things.

Categories
Gadgets Geekery Raspberry Pi

Raspberry Pi LED scrolling sign

I’ve been playing around with LED scrolling signs for a while now and have been looking for an affordable sign to use for a project. Some LED signs are really expensive but I’ve recently come across this one from Embedded Adventures:

It’s a 80×8 display with three colours – Red Green, and Red/Green mixed to produce Orange. It measures about 35x4cm in size so is ideal for something eye catching.

Best part is that it’s available for just £20 from the Embeded Adventures website. It’s ready assembled so you don’t have to get out your soldering iron.

To connect to your Pi’s GPIO follow the instructions on this page – which includes a handy python script by Pete Goss. For the wiring guide note that the numbers refer to the number of the pins as you count across, not the GPIO number. This is also for the Rev 2 board model A or B (if you have mounting holes, your Pi is fine).

Raspberry Pi pin number (GPIO pin label) LDP-8008 pin number (label)
3 (GPIO 2) 2 (A row address)
5 (GPIO 3) 4 (B row address)
6 (GND) 5 (GND)
7 (GPIO 4) 6 (C row address)
8 (GPIO 14) 7 (EN enable display)
10  (GPIO 15) 8 (D row address)
11 (GPIO 17) 9 (red LED)
12 (GPIO 18) 10 (green LED)
13 (GPIO 27) 14 (latch)
15 (GPIO 22) 16 (shift)

There’s a slight errata on the page as you have to type:

sudo python scroll “Raspberry Pi” 1

to get it to work.

I found that it will work powered just from the GPIO of the Pi, but if you need a brighter display you can just hook up a 5 volt power supply (e.g. a spare USB charger) to the central pins – this doesn’t need to be connected to anything else. The lower pin (with the printed text on the back the right way up) is ground – I used the cable off a novelty LED light from Poundland.

For the cable you can use jumpers or for something more permanent I found this Maplin GPIO breakout board available for £3.49 to be ideal. The LDP8008 comes supplied with a ribbon cable you can use.

Here’s a closeup of my cable – by cutting the grey cable different lengths you can make it quite neat. I also added a plastic cover cut from a spare toolbox divider.

underside of the maplin breakout board
underside of the maplin breakout board

and the cable attached to the GPIO on the Raspberry Pi (make sure you get pin 0 on the right side!)

I was surprised at how neat this turned out...
I was surprised at how neat this turned out…

Note that in my case, the labels on the Maplin GPIO breakout board were incorrect – make sure you double check everything before plugging it into your PI so you don’t break it!I also found the display a little sluggish if anything else is running.

For extra neatness I mounted the whole setup in a box frame – the one I used came from Wilkinson’s and was £6.

endless office fun...
endless office fun…
Categories
Comment Gadgets Geekery Raspberry Pi

Kano the Raspberry Pi go mainstream?

Since its launch the Raspberry Pi has been phenomenally  successful – with over 2 million units of the little computer sold around the world, it’s arguably kick-started a revolution in cheap, educational computing.

The only slight worry about this is how many Raspberry Pi computers have landed in the hands of kids (who it was really intended for) as opposed to 30-something computer nerds who are re-living their 8-bit computing childhoods, or networking the family toaster. Arguably there’s nothing wrong with that as the enthusiasts provide a ton of support but sometimes it’s easy to lose site of the goal of the project in the first place.

Then there’s the Raspberry Pi’s biggest competitor – the tablet computer. Many kids will be given tablets as they’re ‘educational’ devices – and given the choice of an instant on, readily usable ipad that can play games as well, the Raspberry Pi has its work cut out to avoid the drawer of forgotten devices.

So enter the Kano project – a kickstarter that raised over 1 million dollars, and effectively bundles the Raspberry Pi up with some nice hardware and some trendy design. Marketed as the computer you can build, it’s taking aim at the educational market in the hope that the kids will put down their iPads and have a go.

The Beta version of the Kano OS software part of the project launched this week so here are some first impressions.

In order to prepare your SD card Kano requires a burner program to run on a PC or Mac – although this does the job, it’s not quite as elegant as the NOOBS drag and drop method which has now become the standard for most Raspberry Pi software.

It did work on the first attempt
It did work on the first attempt

On bootup you get asked a few questions in the terminal, in the style similar to a text adventure. This is actually a rather nice touch. It neatly introduces the idea of the text interface and entering commands, and makes typing startx rather exciting (there’s a countdown!). I can imagine this being fun with a classroom of kids trying out the Raspberry Pi for the first time.

Not the command line you know
Not the command line you know

This first person theme continues as you use the computer – one nice touch is the bundled wi-fi setup app asks you to test your internet connection with the ping command (thus introducing the idea for later).

Once you get past this you’re presented with the Kano desktop. It’s beautifully designed with nice flat icons for the various apps. Chromium is the default web browser and it runs at a decent speed, and there are some bundled apps for creating programs.

Even as a Beta it feels quite polished.

Overall Kano OS is much simpler and less cluttered than other Raspberry Pi distributions and everything you really need is still there.

The tabletty desktop
The tabletty desktop

Lots of things here will be already familiar to anyone who’s used a Pi before – the command line is still accessible, so despite its user friendly interface there’s still the option to type proper linux commands.

The apps that have had the most work done to them are the programming tutorials – these allow you to mess around with a game of snake or pong using the drag and drop interface of scratch, and there’s also a split screen Minecraft app that is quite clever. It doesn’t take long at all to start really using the Pi and trying out different projects.

Here's pong with garish colours!
Here’s pong with garish colours!

It’ll be interesting to see how this software progresses – there are definitely some good points, and as something I could load onto a Raspberry Pi and give to some kids to play with it perfectly fits the bill; and it does still include the vital command line for anyone that gets curious as to what’s running their computer behind the scenes – something that a tablet computer lacks.

One thing I wonder though is exactly how the Kano kit fits in with the other Raspberry Pi distributions – I’m not sure if the aim is to get this to fit alongside the other Raspberry Pi distributions (for instance including it as part of NOOBS) or to sell it separately. Raspbian’s open source nature has led it to be massively improved over the years by the community – and it would be a shame if Kano OS missed out on this.

You can try out Kano for yourself at kano.me

The kit launches sometime this year with a custom keyboard – I’ll be reviewing that as well.