Posts tagged: maplin

Ooh Arr-duino

Santa this year was very generous to my son and gifted him with a Maverick Atom XT RTR 1/18 Electric 4WD Truggy but failed to mention that the batteries that came with it could only be left in the charger for 6 hours, no longer. With grave warnings about explosions and fire, I tried to find an egg-timer on a socket kind of solution, but could not find anything that would go beyond 4 hours.

So what is a tinkerer to do? He makes one himself! ;)




A long time ago I bought an Arduino, but never really got any further with it than a blinking RGB led. Now I finally found a purpose for it :) I was going to build an Arduino controlled timer socket!

All I needed now were some kind of relay, some sockets, a few buttons and a way of letting the user my son know what the time was set to and if it was on or not. I ended up with a Ciseco Arduino Relay Shield, two Maplin push-to-make switches, a DFRobot I2C 16×2 LCD and a Maplin project box big enough to fit it all in

First a small word of warning. You are dealing with MAINS voltage, which can be lethal if you fool around. DO NOT EVER! connect the bits to mains power when parts of it are exposed. You’ve been warned

I started off with a small mockup of materials and then got my trusty Dremel clone out and started cutting away at the project case.

First off is the socket in which the battery charger can be plugged. A small template on paper is by far the easiest way to make sure you don’t cut out too much behind the socket

With the socket in place, I created the template for the LCD. I took my time with this, as I didn’t want to cut out too much. A lot of careful sanding ensured that only the black part would be visible, and nothing else. Then with the help of some small bolts and nuts, I created some spacers, enabling the LCD to sit nicely in the cutout. Lots of hotglue completes the mounting

The buttons only required some measuring to make sure they are neatly symetric and do not interfere with the LCD

All that remains is the IEC socket where the power will go into the project box

Now with everything in place, all we need to do is connect the components together with some wire using the below schematic

Warm up the soldering iron and just follow the diagram. As my soldering skills are not that great, I also used a bit of heatshrink here and there to make sure that wires could not short on each other :)

I’m using an old iPhone charger to power the Arduino as it provides a neat 5V/1A, with a small retractable USB lead with a Type A to B converter. A quick test of the wiring to make sure it all works as planned

Now with construction over, it was time to do the Arduino coding. The LCD uses the LiquidCrystal I2C library which takes care of all the hard work interfacing to it. Likewise, the Metro library takes care of the timer. So, it is just a simple case of increasing the clock by an hour every time the red button is pressed, and starting the timer when the green button is pressed. Once the timer is running, any button press will stop the timer and reset the state to the beginning.

// Arduino controlled timer socket
// (CC BY) 2011
// http://awooga.nl
 
// pull in libraries
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Metro.h>
 
 
// arduino pins constants
#define RELAY 2 // black wire connected to input on shield
#define RED   6 // green wire
#define GREEN 7 // white wire
 
// i2c pin A5 = white wire
// i2c pin A4 = green wire
 
// allow between 1 and 6 hours
#define MINIMUM_TIME 1
#define DEFAULT_TIME 6
#define MAXIMUM_TIME 6
 
 
const unsigned long MILLISECONDS=1;
const unsigned long SECONDS=(1000*MILLISECONDS);
const unsigned long MINUTES=(60*SECONDS);
const unsigned long HOURS=(60*MINUTES);
const unsigned long DAYS=(24*HOURS);
 
const unsigned long UNITS=HOURS;
 
 
// prgram states
#define IDLE         0
#define RED_BUTTON   1
#define GREEN_BUTTON 2
#define MENU         3
#define PAUSE        4
#define STOP_TIMER   5
#define CANCEL_TIMER 6
 
 
// global variables
byte events;
byte countdowntime;
boolean menu_running;
boolean timer_running;
 
boolean debug = false;
 
byte currentRed = LOW;
byte currentGreen = LOW;
byte previousRed = LOW;
byte previousGreen = LOW;
 
// set the LCD address to 0x27 for the 16x2 display
LiquidCrystal_I2C lcd(0x27, 16, 2);
 
// initiate Metro object
Metro relayMetro = Metro(0, true);
 
 
// arduino setup routine
void setup() {
 
  // set the arduino pins
  pinMode(RELAY, OUTPUT);
  pinMode(RED, INPUT);
  pinMode(GREEN, INPUT);  
 
  // initialise the lcd
  lcd.init();
  lcd.backlight();
 
  // activate debugging on the serial port
  if (debug) {
    Serial.begin(9600);
    Serial.println("Lets go!");
  }
 
  // initialise variables
  events = IDLE;
  countdowntime = DEFAULT_TIME;
  menu_running = false;
  timer_running = false;
  digitalWrite(RELAY, LOW);
}
 
 
// arduino loop routine
void loop() {
 
  switch (events) {
 
    case IDLE:
      events = Idling();
      break;
 
    case MENU:
      events = MainMenu();
      break;
 
    case RED_BUTTON:
      events = RedButton();
      break;
 
    case GREEN_BUTTON:
      events = GreenButton();
      break;
 
    case PAUSE:
      events = Pause();
      break;
 
    case STOP_TIMER:
      events = StopTimer();
      break;
 
    case CANCEL_TIMER:
      events = CancelTimer();
      break;
 
    default:
      events = IDLE;
      break;
  }
}
 
 
int MainMenu() {
 
  if (timer_running) {
    return IDLE;
  }
 
  if (menu_running) {
    return IDLE;
  }
 
  if (debug) { Serial.println("MainMenu()"); }
 
  lcd.clear();
  lcd.print("  Red: Set time");
  lcd.setCursor(0, 1);
  lcd.print("Green: Go (");
  lcd.print(countdowntime, DEC);
  if (countdowntime == 1) {
    lcd.print("hr)");
  }
  else {
    lcd.print("hrs)");
  }
 
  menu_running = true;
 
  return IDLE;
}
 
 
int Idling() {
 
  boolean do_red = false;
  boolean do_green = false;
 
  if (timer_running) {
    if (relayMetro.check()) {
      return STOP_TIMER;
    }
  }
 
  currentRed = digitalRead(RED);
  currentGreen = digitalRead(GREEN);
 
  if (currentRed != previousRed) {
    do_red = (currentRed == HIGH);
  }
  previousRed = currentRed;
 
  if (currentGreen != previousGreen) {
    do_green = (currentGreen == HIGH);
  }
  previousGreen = currentGreen;
 
  if ((do_red) && (!do_green)) {
    return RED_BUTTON;
  }
 
  if ((!do_red) && (do_green)) {
    return GREEN_BUTTON;
  }
 
  // all other button combinations are ignored
  return MENU;
}
 
 
int RedButton() {
  if (debug) { Serial.println("RedButton()"); }
 
  if (timer_running) {
    return CANCEL_TIMER;
  }
 
  if (++countdowntime > MAXIMUM_TIME) { countdowntime = MINIMUM_TIME; }
 
  lcd.clear();
  lcd.print("Time set to");
  lcd.setCursor(0, 1);
  lcd.print(countdowntime, DEC);
  if (countdowntime == 1) {
    lcd.print(" hour");
  }
  else {
    lcd.print(" hours");
  }
 
  menu_running = false;
 
  return PAUSE;
}
 
 
int GreenButton() {
  if (debug) { Serial.println("GreenButton()"); }
 
  if (timer_running) {
    return CANCEL_TIMER;
  }
 
  lcd.clear();
  lcd.print("Running timer");
  lcd.setCursor(0, 1);
  lcd.print("for ");
  lcd.print(countdowntime, DEC);
  if (countdowntime == 1) {
    lcd.print(" hour");
  }
  else {
    lcd.print(" hours");
  }
 
  unsigned long t = countdowntime * UNITS;
 
  timer_running = true;
  if (debug) {
    Serial.print("Setting metro for ");
    Serial.print(t);
    Serial.println(" seconds");
  }
  relayMetro.interval(t);
 
  digitalWrite(RELAY, HIGH);
 
  return IDLE;
}
 
 
int StopTimer() {
  if (debug) { Serial.println("StopTimer()"); }
 
  digitalWrite(RELAY, LOW);
 
  lcd.clear();
  lcd.print("Timer finished");
 
  timer_running = false;
  menu_running = false;
  relayMetro.reset();
 
  return PAUSE;
}
 
 
int CancelTimer() {
  if (debug) { Serial.println("CancelTimer()"); }
 
  digitalWrite(RELAY, LOW);
 
  lcd.clear();
  lcd.print("Timer stopped");
 
  timer_running = false;
  menu_running = false;
  relayMetro.reset();
 
  return PAUSE;
}
 
 
int Pause() {
  delay(1000);
  return IDLE;
}

Or just download the .pde file here

Obviously you can go all crazy with options and clocks, but I just wanted something quick and working. Changing the code to do all that is just a matter of opening it up, and uploading the new software.




And just to prove it is all working, here’s a small video demonstration. It doesn’t show the timer ending, you just have to take my word on that :D

The Eee PC Digital Picture Frame

I just can’t help myself. It all started way back in 2002 with The Swedish Chef, followed in 2005 by the (still) popular Project Bling: the desire to create the ultimate digital picture frame.

So here it is, the third (and hopefully last) instalment: The Eee PC Digital Picture Frame aka The Eee PF.

I’ve divided it up in four sections, for easy digesting ;) All pictures can be enlarged, and the complete set of pictures can be found in the gallery.

Part 1: Disassembling the Eee PC
Part 2: Mounting the LCD
Part 3: Building the frame
Part 4: Finishing touches




Part 1: Disassembling the Eee PC

It starts off with an Asus Eee PC 701 2G, which is perfectly small, yet cheap enough to destroy in the name of science.

Asus Eee PC 701 2G

Push the three tabs at the top of the keyboard in and lift the keyboard up to reveal the keyboard connector at the bottom of the keyboard. Using a small flat screwdriver, push the two locks open and remove the keyboard completely. Next to the keyboard connector is the touchpad connector which should be disconnected as well.

With the keyboard removed, the bottom half of the case is next. Remove the nine screws as indicated in the pictures. Turn the Eee PC over and remove the six remaining screws. For good measure, also remove the battery by sliding the two latches outwards, and slide the battery out. Flip the Mini over again and open the lid again. Using a plastic wedge (or your finger nails if you have them), pry the case open using some gentle force along the sides. Be patient at this point as the plastic latches inside the case, are fragile and will snap if you exercise too much force.

Now we just need to remove the motherboard. Disconnect the speaker and display connectors. There are two latches holding it in place, located at the bottom edge of the PCB. Lift the motherboard up at the right hand side and then pull it out up and sideways.

Time to separate the LCD from the bezel. Six screws are hidden underneath the plastic covers which are stickied in place. Use a plastic wedge along the side of the bezel but be very careful, it is very fragile. Take your time and be gentle. Just four screws and four sticky metal tape strips to remove before you can lift the LCD clean out.

Voilà, the Eee PC naked! Now we are ready for some serious modding ;)

The Eee PC dissected
 

Part 2: Mounting the LCD

Whatever you do, make sure you buy a frame and mount which have a high WAF since it needs to live in the living room. You don’t want to find yourself building something like this and then SWMBO tossing it in the bin because is clashes with the design ;) Take the mount and measure the dimensions of the LCD and frame and carefully cut it to size. As usual; measure twice, cut once :)

The LCD driver board sits neatly underneath the LCD, but when you mount the display into the frame, it doesn’t fit. Cutting away a bit of the frame allows it to be sunken into it and sit flush with the frame. Some double sided tape holds the mount in place.

On to the motherboard. This needs to be mounted with enough clearance above the LCD so that heat can escape and to do this I made my own spacers using normal motherboard spacers which I had plenty of from my PC building days. The screw holes on the Eee PC are tiny, so cut away at the top of the spacers to make them small enough to fit. Looks rather neat, eh?

The Eee PC mounted
 

Part 3: Building the frame

Before we create the frame, we need to think about an alternative heat sink. Normally, the bottom of the keyboard would dissipate the heat, so after doing some testing, I settled on an Akasa Southbridge cooler and some tiny Maplin heat sinks. Tests showed that the temps remained nicely around the 50ºC mark, which will rise to about 65ºC once the back cover will be on. Well within the limits :)

Using some 4mm Pine Stripwood cut to length, mark out all the ports and crevices that need to be carefully removed from the frame to allow access once everything is closed up again.

Here’s a quick mock up of how it all will fit together once we’ve painted the frame and glued it to the photo frame’s back.

The Eee PC framed

Because the power switch would be covered up when the back is glued on, we need to move the switch’s function to somewhere more convenient. Reading this blog post over at Infinity Squared on an external power switch, I decided to go for the smallest I could find at Maplin. My soldering is definitely not the best, so a bit of heat shrink camouflages most of it ;)

I also wanted to have some sort of visual indication that the frame is on or off (other than the tell-tale display ;)). But how to get the minuscule surface mounted LEDs displayed through the frame? I had seen something previously, where light was transported using a small transparent acrylic tube. And when I was killing some time wandering around my local Tesco, I found my 48p answer… translucent golf markers! Remove the heads, drill a few holes and Bob is a relative.

Almost there. Using some left over black paint, paint all the sides and make sure that once assembled, all the small blemishes are hidden. Well, most of them ;)

Ready for assembly! Some glue, some patience and some skilful balancing of weighty items on top of the corners and all that is left to do is add the back cover.

The Eee PF framed and painted
 

Part 4: Finishing touches

A sheet of hardboard has been cut to be the approximate size and then using patience and lots of sanding made to fit exactly. The space at the bottom of the frame is perfect for the speakers, so using a small drill, create lots of small holes where the sound can penetrate through. It won’t be high fidelity, but it’s good enough for announcements. At the top of the frame, the microphone has been mounted, so we may be able to support voice commands in the future! A quick lick of paint finishes it off.

We’re re-using the stand from the picture frame, but instead of hammering it in the backboard, we have to glue it. I’ve used Araldite, which should create a long lasting strong bond.

And that is it! I’m quite pleased with the result, and even SWMBO commented on how nicely it looks in the living room… result!

The Eee PF finished

As a final note, I haven’t mentioned at all what software the frame is running, so before you bombard me with questions, I better list them here ;)




The OS is a standard Ubuntu 8.10 Desktop, with /usr compressed with squashfs/unionfs so it can fit on the 2GB SSD. After booting, it starts Firefox on my homepage, a PHP/Ajax/MySQL slideshow script which displays the pictures, weather and clock. The mousepointer is hidden using a small utility called Unclutter and the display is automatically switched off at night using sudo vbetool dpms off and switched on again in the morning using sudo vbetool dpms on. It’s still all a bit rough round the edges, but for now it works :)