Posts tagged: lcd

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 :)

RecyBling

I am a firm believer in recycling and am of course signed up to my local Freecycle group. Anything to good to throw away ends up there, but for one item I’ll make an exception… Project Bling! I’m still getting loads of visitors on that page, so someone out there can save himself a bit of work by getting the real deal. Just contact me and for the price of shipping it can be yours!

Update 19.5.2008

I’m sorry, but you are too late. The frame has been recycled

The TiVo LCD Project

Flash of the past alert! It was way back in 2003 that I did a small modding project involving my favourite gadget of all time the TiVo and a small character LCD and created a mini How-To for it. I thought I lost the article forever when I accidentally deleted the web pages in one of my (many) server moves. Not so! A certain BobBlueUK knew his way around The Wayback Machine (unlike me) and digged up the original archived copy!

So in all its glory, here it is again :D




Ever wanted to find out what the TiVo is doing? Look no further :) On this page I will describe a way for you to display the program information on a small LCD display. It is only to be taken as a proof of concept, I’ll leave the actual mounting and cosmetics up to someone else.

Components

  1. A warranty voided TiVo
  2. A serial LCD. Mine is a 2×20 LCD pre-fitted with a BPK driver board from Milford Instruments, part number 6-121 @ £30.00
  3. A bit of cable with 3 wires (like cat5)
  4. A 3.5mm stereo jack plug with plastic barrel and strain relief sleeve from Maplin Electronics, part number HF98G @ £0.79
  5. A Futaba Servo Connector from Maplin Electronics, part number GZ94C @ £1.49
  6. 2x 4-Pin 5.08mm (0.2in.) Spacing Polarised Power Connectors (one male, one female) from Maplin Electronics, part numbers JW64U and JW65V @ £0.79 each. These things are better known as molex connectors
  7. A patient SWMBO

TiVo LCD Project

Instructions

The most tricky part of this project is opening up the TiVo, so best invite Stuart Booth over who can do it blindfolded using only his nose to guide him ;-) If he’s not available you will have no choice but to do it yourself, so get a Torx T10 screwdriver and remove the 3 screws at the back of the TiVo. THIS WILL VOID YOUR WARRANTY, but I guess you did that already when you installed the Turbonet card and added a nice big hard disk, right? ;-)

TiVo LCD ProjectWith the TiVo opened, you need to put the 2 molex connectors (item 6) to work by making up a splitter which is put in between the hard disk and the power supply. BE VERY CAREFUL AROUND THE POWER SUPPLY! That thing is lethal as it maintains the charge even after it has been switched off for several hours/days. Anyway, the thing you have to bear in mind is that you need to connect all wires on the molex connectors, and on to the +5V and GND (Ground) add two wires which you need to feed to the outside of the TiVo. I used the same space as where my cat5 cable is going out of the TiVo (the one connected to the Turbonet card), just underneath the fan.

Then it is soldering time… Take the 3.5mm stereo jack and connect a wire to the tip of the connector. That was soldering time :-)

TiVo LCD ProjectNow take all 3 wires (and make sure you have them appropriate coloured, like red for +5V, black for ground and any other colour for the TX (transmit), and connect them to the Servo connector, making sure that you do them in the same order as there are pins on the LCD. My LCD has 3 pins, labelled +5V, GND and Recv (receive), which makes it pretty obvious which wire goes where. Your mileage may vary of course.

Time to test it methinks :-) Close the TiVo and hook it up in your AV setup and power it up again. The LCD display should now be powered, and depending on what model/type you are using it might display something (like garbage or a version number) or in my case, a blank screen with just the backlight on.

Pat yourself on the back, the hard work has been done. Now it is back to the good old computer and open up a telnet and ftp session to the TiVo as you need to install a small .tcl script written by a TiVo community user called Demark. He posted it to this thread and all I had to do was modify it slightly to output the lines correctly. You can find my copy here.

TiVo LCD Project

Install the .tcl file in /var/hack and run it with the ‘&’ to detach it from your shell, otherwise you will reboot your TiVo when you try to interrupt it. To stop the script you simply do a ‘touch /tmp/vfd.stop’ and within a minute the script will stop. Make sure you remove the /tmp/vfd.stop file before you start it again though.




It is quite possible that I’ve skimmed over something which I think is trivial to do, but proves a real nightmare for you, so if you got any questions, please don’t hesitate to contact me. Good luck modding!

Famous

In the future everyone will be world-famous for 15 minutesAndy Warhol

So here are a few of the sites linking to Awooga!!!:

Digg.com (where it all started)
Automated Home UK
eHomeUpgrade
Nordic Hardware (Swedish!)
LiveCD News
TousPourUn (French!)
Paul’s Blog

Project Bling

Ever had the desire to display your digital pictures in a frame without going through the hassle of printing them and re-framing? My inspiration came from the write up on Applefritter and I decided to take the plunge and destroy a hand-me-down IBM Thinkpad 560X in the name of science ;)

Project Bling

Over the space of a couple of days, I disassembled the laptop and carefully assembled only the bare minimum required parts on the back side of a wooden picture frame. I’m quite pleased with the result if I say so myself :)




We start off with an old laptop, and remove all the plastics to get it as thin as possible. Make sure you test the laptop after you finished.

Now it is time to slowly put everything together again inside the pictureframe.

Make sure that you can still access the vital ports on the laptop after it is closed.

Until I’ve sorted out a proper on/off solution this little stick will do just fine ;)

And finally, this is what the finished product looks like.






Have a look in the gallery for some more pictures