Retro Space Invaders Gmail Notifier
A couple of weeks ago I was in our local Boots chemist. They were clearing out all the Christmas gifts at 75% off.  I saw this Space Invaders alarm clock reduced to around £3 ($5) and had to have it, even though I had no use for another alarm clock.  (Btw, even though Boots are now sold out, the same clock is available from Play, IWOOT, Menkind and others.)
The challenge was… what to do with it?
In the end I decided to turn it into an ambient device, connected to the internet and capable of alerting me when things happen. Right now I’ve got it firing up with a new message arrives in my Gmail inbox, but really it could do anything – flag up Twitter replies, indicate the chance of rain or even, paired with one of my previous projects, act as an additional ringer for the doorbell.  I’ve added a row of LEDs (three red, three yellow) to give it some more feedback options.
Every time I get a new email the clock moves from side to side and does the classic Space Invaders sound, then lights one of the LEDs to give me an idea of how many unread messages there are. Â There’s loads more that could be done with it, but I was happy just turning it into something more useful without destroying it in the process.
If you want to make one yourself, here’s what I did…
I used an Arduino to give the clock some more logic. I didn’t want to alter the external appearance of the clock and space was incredibly tight inside, so I used an Arduino Nano clone that I had lying around.
Update: I’ve since written a post with a parts list and some setup instructions that may be useful to read in conjunction with this.
First step was to get the components working on a breadboard. I ran 6 LEDs off the Arduino’s digital pins and added an opto-isolator to another digital pin to act as a switch. I knew the Arduino wouldn’t be able to drive the clock’s motor straight off an IO pin, so my plan was to simply trigger the clock’s handy ‘demo’ button from the pin and deliver the main clock/motor power from the direct 5V pin on Arduino.
Here’s the wiring layout that I ended up with…
The original power source for the clock was 3 AA batteries producing around 4.5v. I was planning to power the clock directly over USB – I figured 5V was close enough – so the battery compartment provided the perfect space to house the additional components. Unfortunately the battery box wasn’t quite deep enough for the Nano, so my first job was to cut out the battery recess with a craft knife. I left a small lip on the bottom edge to support the additional components and to retain the original motor mounting point.
With a bit of breadboard trimming (with a hacksaw… quick and nasty!) I was able to fit it into the clock…
Next step, the Arduino sketch. The code is currently dead simple: listen to the serial input and if it’s a number, light that many LEDs; if the new number is higher than the old number (i.e. you’ve got new emails, not just cleared out old ones) then also close the ‘demo’ switch to activate the sound and movement. Here’s the finished code.
int ser = 0; // for incoming serial data int prevCount = 0; int timer = 100;
void setup() {
for (int thisPin = 2; thisPin <= 13; thisPin++) {
pinMode(thisPin, OUTPUT);
}
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}
void loop() {
if (Serial.available() > 0) {
// read the incoming byte:
ser = Serial.read();
if (ser >= 48 && ser <= 58) {
int newCount = ser - 48;
if (newCount > 0 && newCount > prevCount) {
digitalWrite(12, HIGH);
delay(100);
digitalWrite(12, LOW);
delay(1500);
digitalWrite(12, HIGH);
delay(500);
digitalWrite(12, LOW);
}
prevCount = newCount;
} else {
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13,LOW);
}
}
for (int thisPin = 3; thisPin <= 11; thisPin++) {
digitalWrite(thisPin, LOW);
}
int topPin = prevCount + 2;
for (int thisPin = 3; thisPin <= topPin; thisPin++) {
if(thisPin <= 5) {
digitalWrite(thisPin, HIGH);
} else {
digitalWrite(thisPin+3, HIGH); // Because I left a gap in the digital pins
}
}
}
The last step was to write a quick script to poll Gmail and get the number of unread messages. Â I’ve tried lots of different languages for Arduino serial control in the past – Perl, PHP and DOS shell scripts – but every time it’s been a little bit flakey, at least under Windows. Flash Actionscript is pretty reliable using Serproxy, but that was overkill for this project. So in the end I decided to give Python a go. It was a good choice – reliable and really quick to implement. Â Here’s the code…
import serial import time import imaplib
ser = serial.Serial('COM6', 9600)
time.sleep(2)
while True:
obj = imaplib.IMAP4_SSL('imap.gmail.com','993')
obj.login('GMAIL_USER_HERE','PASSWORD_HERE')
obj.select()
obj.search(None,'UnSeen')
count = len(obj.search(None, 'UnSeen')[1][0].split())
if(count > 9):
ser.write(':')
else:
ser.write(count)
time.sleep(120)
ser.close()
The only bit that had me scratching my head was Arduino’s trick of resetting every time the serial line is opened. Â The Nano takes around 1.5 seconds to restart, meaning it would always miss the first mail notification. A wee sleep command fixed that.
And that’s about it. Three hours and around £12 of components (including the Nano clone) to turn an alarm clock into a Gmail notifier.
Future scope
There are still lots of free pins on the Nano, so plenty of scope for expansion. A light sensor could be a useful addition so it doesn’t trigger when the room lights are off, and maybe a knock sensor so it could be set to ‘snooze’ with a quick tap. Apart from that, most other mods would be software-based. I might make the three red LEDs linked to Gmail and the yellow ones linked to Twitter.
If you decide to make one of your own please let me know. Â And if you make any improvements to the software, please share!
Update: The response to this hack has been phenomenal – thanks for all your emails and feedback. Here are some of the mainstream sources that have picked up on it.
- Make Magazine:Â Space Invaders Gmail Notifier
- Engadget:Â Arduino hack turns Space Invaders alarm into Gmail Notifier
- Ubergizmo:Â Space Invaders Gmail notifier
- Technabob:Â Space Invaders Alarm Clock Becomes a Gmail Notifier
- Engadget Español
- How-To Geek
On Twitter:
On YouTube:

[...] has schematics and code on his [...]
Pingback by Space Invaders Gmail Notifier — February 6, 2012 @ 4:08 pm
[...] has schematics and code on his [...]
Pingback by Space Invaders Gmail Notifier | House of Mods — February 6, 2012 @ 7:25 pm
[...] realidad se trata de un reloj-despertador modificado por un fan de la electrónica y los Space Invaders que generosamente te cuenta cómo lo hizo por si quieres uno igual, solo para [...]
Pingback by Notificador de e-mail Space Invaders — February 6, 2012 @ 9:44 pm
[...] decided to turn impulse buy lemons into hacker lemonade. Now, after a month of work, Grant has turned the clock into a GMail and Twitter notifier for his [...]
Pingback by Space Invaders Hack Turns Your Unread Email Into a New High Score - Fix-Singh :: Fix-Singh — February 6, 2012 @ 10:10 pm
[...] Nano ainsi qu’une petite Breadboard et deux rangées de LED rouge et jaune.Avec un peu de programmation, et un petit script en Python, les notifications de Gmail sont envoyé à travers le port série [...]
Pingback by DIY : Un Space Invaders qui vous signale les notifications de Gmail | Semageek — February 7, 2012 @ 12:35 am
[...] decided to turn impulse buy lemons into hacker lemonade. Now, after a month of work, Grant has turned the clock into a GMail and Twitter notifier for his [...]
Pingback by ALL ABOUT GADGET » Space Invaders Hack Turns Your Unread Email Into a New High Score — February 7, 2012 @ 12:40 am
[...] decided to turn impulse buy lemons into hacker lemonade. Now, after a month of work, Grant has turned the clock into a GMail and Twitter notifier for his [...]
Pingback by Space Invaders Hack Turns Your Unread Email Into a New High Score — February 7, 2012 @ 2:59 am
[...] decided to turn impulse buy lemons into hacker lemonade. Now, after a month of work, Grant has turned the clock into a GMail and Twitter notifier for his [...]
Pingback by All Game Newsgame — February 7, 2012 @ 3:05 am
I’m running a similar python script for my door opener. I’ve found that it will abort with and EOF error after idling for sometime. I just caught the error in the script and executed the login once more.
Comment by Vishnu — February 7, 2012 @ 5:13 am
[...] happy just turning it into something more useful without destroying it in the process. Grant has schematics and code on his [...]
Pingback by Space Invaders Gmail Notifier - Free Plans, Hacks, Howto's and other DIY stuff - Free Plans Online — February 7, 2012 @ 8:02 am
[...] has schematics and code on his [...]
Pingback by Space Invaders Gmail Notifier « « SNAP-DIYSNAP-DIY — February 7, 2012 @ 9:07 am
@Vishnu #9 – that’s good to know. I haven’t encountered any EOF errors yet, but will keep that in mind!
Comment by Grant — February 7, 2012 @ 1:09 pm
I’m guessing you dont really need a clock display
so maybe figure out how to drive the LCD and have it display:
unread emails?
and then return to the time after its done?
Comment by kevix — February 7, 2012 @ 11:06 pm
[...] has schematics and code on his [...]
Pingback by High Technology » Blog Archive » Space Invaders Gmail Notifier — February 8, 2012 @ 12:20 am
[...] about last year? It was pretty cool by itself, but now it has become even more functional. Designer Grant Gibson turned his into an awesome Gmail notifier. He pulled out the battery pack and put an Arduino Nano [...]
Pingback by Space Invaders Alarm Clock Becomes a Gmail Notifier - Technabob — February 8, 2012 @ 1:01 am
[...] Pare inoltre che l’orologio continui a funzionare, ma senza la necessità delle batterie. Se vi interessa realizzare qualcosa di simile, per rendere divertente la vostra scrivania, trovate tutte le istruzioni sul sito dell’hacker. [...]
Pingback by Una sveglia di Space Invaders notifica mail e tweet | — February 8, 2012 @ 4:04 am
@kevix #13 – Yeah, you’re absolutely right. I took a look at the LCD interface but to be honest it scared me! There are approx 12 contacts exposed on the PCB and the LCD itself has no marked contacts – it just seems to be the pressure when screwed together that makes the contacts.
There’s no obvious way that the 12 contacts map to the 32 LCD segments in the clock, so I reckon it we’d need to reverse engineer the protocol before we could take over the LCD.
Definitely possible, but beyond my 2-3 hour hack window each week.
If anyone has a go at that, please post your results back.
Comment by Grant — February 8, 2012 @ 11:02 am
Awesome. i think those clocks would be out of stock soon. Is the reverse possible? i.e. send an email when someone shakes the clock? You might be able to pick up the current generated when the motor is moved by someone.
Comment by Tharaka Devinda — February 8, 2012 @ 2:15 pm
@Tharaka – Yes, absolutely. The circuit board already has a simple motion sensor that could be intercepted by the Arduino. Or for a non-destructive hack, a simple knock sensor would give the same result – e.g. http://www.arduino.cc/en/Tutorial/KnockSensor
Comment by Grant — February 8, 2012 @ 3:12 pm
[...] to have on a desk, specially if you are proud to show-off your geeky side. Like the Designer Grant Gibson who has not only used this device to get off the bed in the morning, he has also turned this into [...]
Pingback by Space Invaders Alarm Clock + Gmail Notifier - JeradPost — February 8, 2012 @ 8:14 pm
I think it’s terrific. I’m pretty much a novice but would l would love to attempt building it. Any chance you could provide a step by step on the electronics and coding?
Comment by Bob Popper — February 8, 2012 @ 8:36 pm
[...] einer für ca. 4€ erstandenen Space Invaders Uhr hat Grant einen Arduino-basierten Gmail-Alarm [...]
Pingback by Space Invaders Uhr zum Gmail-Alarm umgebaut | Homemade Gadgets — February 8, 2012 @ 9:20 pm
@Bob #21 – Thanks for the feedback. I will aim to do a full ‘from scratch’ walkthrough at some point, but I reckon that might take me a while to pull together. Although each of the steps is pretty simple there are just a lot of them!
Until I do a guide, a good place to start is to pick up an Arduino, download the free software from arduino.cc and work through a few of the included software examples. The arduino.cc site has a lot of good resources and help if you get stuck (or please feel free to ask me).
Comment by Grant — February 9, 2012 @ 10:59 pm
Please include information on running the python script. Newbs are more familiar with arduino than Python. I have spent hours trying to figure out how to run the Python script.
Comment by Peter — February 14, 2012 @ 3:58 pm
@Peter – sorry to hear that’s been causing you problems. I’m a bit of a Python noob myself and it took me a wee while to get Python and pySerial working well together. I’ll update this article to link to the later post on config.
Comment by Grant — February 15, 2012 @ 8:36 am
[...] The clock was given some more logic with the use of an Arduino. To check if the circuit will work, the components were connected initially on a breadboard. The USB-powered Arduino Nano was installed to the stripped battery compartment and was programmed to poll the email and activate the motion whenever a new message was received. This was done through a script. [...]
Pingback by Gmail Notifier made from Modified Space Invaders Alarm Clock | HACKOLOG - Amazing Hacks and Mods — April 15, 2012 @ 8:19 pm