Space Invaders Gmail Notifier – parts summary

<![CDATA[Wow! I've been blown away with the amount of interest in my wee Space Invaders alarm clock modification. Thank you everyone!

Four days on from my original blog post my YouTube video has been viewed over 11,000 times and details of my project have spread right around the globe, translated into German, Spanish, Portuguese and French… and others I'm still finding!

I've posted the code and the circuit online for anyone else who'd like to try it, but I've had a lots of first-time Arduino users asking for a complete "from scratch" guide via Twitter, email and in the online comments.

I guess from a standing start – without experience of coding and/or electronics – there's quite a lot to it, so I'll make a start for anyone who wants to have a go themselves. Click the link to read more…

Where to start

Before opening up the alarm clock (or even buying one) I’d recommend getting familiar with Arduino and the basic circuit. To get all that working you will need:

  • An Arduino (a Nano model if you want to eventually fit it inside the clock). For regular Arduino projects I’d recommend buying an official Arduino Uno, but when space is tight pretty much any Nano clone will do. You can usually pick one up on eBay for around £10.
  • A solderless breadboard – around £2 – something like this.
  • Some LEDs – pennies each – any old kind… like these.
  • Some 330? resistors – pennies each when bought as a bag – any kind… they don’t need to be as fancy as these.
  • Some jumper wire – any old solid wire will do, but if you’re planning to get into it, invest in a £10 kit like this.

Getting the Arduino set up

Visit arduino.cc and download the latest version of the software, then install it. If you’re using an Uno you’ll be able to start testing it right away, but if you’re using a Nano you’ll also need the FTDI drivers. It’s well worth following this guide to get started.

If you’ve followed the getting started guide linked to in the last paragraph you should have the Arduino environment running and the blink example running on your Arduino board. Congratulations – you’re half way there.

Wiring it all up

To put the circuit together, simply follow the layout in the diagram below. If you’re using a Nano, make sure to leave the bottom row of pins off the breadboard (otherwise the two sides of pins will short together). Make sure the resistors straddle the gap in the middle of the breadboard. You won’t yet have the little white chip at the left of the diagram, and you won’t need the ‘battery terminals’ lines coming off the bottom, but that’s fine for now…

Testing the program and circuit

At this point you can upload the Arduino sketch from my original post. If successful, you shouldn’t really see much of anything happening.

Now the fun bit – open the serial monitor in the Arduino software and type the number 3, then press return. If everything works, 3 of your LEDs should light. Now type 1, 2, 4, 5 or 6. Each time the relevant number of LEDs should light.

The next step is to run the Python script that will drive those numbers – 1, 2, 3, 4, 5, 6 – from your email inbox rather than directly from your keyboard. Download the Python environment and the pySerial serial port extensions and install both following the instructions. Then simply run the Python script from my original post (you may have to change the COM6 value to another number depending on your PC, and you’ll have to enter your Gmail user and password) and, with a bit of luck, you should have the LEDs updating directly from the number of unread emails in your inbox. It’ll probably take a bit of fiddling to get it working, but if you get stuck please feel free to ask me in the comments.

Congratulations, if you’ve reached this point you’ve got the project 90% working. The chip we left out earlier is called an Optocoupler (aka Opto-isolator) like this and it’s job is to basically switch other stuff on and off. It does this using light, so there’s no electrical connection between the two devices (so, in theory at least, the clock can’t blow up the Arduino or vice versa).

If you want to finish the project, just pop in this chip where shown on the diagram and hook up the switch you want to open/close to the other side. In my case I used the wires going to the ‘demo’ button on the clock, but you could just as easily control a button/switch on almost any low voltage (battery powered) device.

Good luck, and please share your results!!!

 

6 thoughts on “Space Invaders Gmail Notifier – parts summary

  1. Grant:

    Nice hack, and thanks for the how-to write-ups.

    One detail I can’t seem to find: how you actually hook up the serial connection? The Nano doesn’t have RS232, and many PCs / most Macs don’t have serial ports (only USB), so I’m a little puzzled how you did the serial connection.

    I generally use an RS232 converter on the Arduino end and a USB-Serial cable on the Mac end, but it would be nice to eliminate the cost of those two pieces in deployed projects…

    Thanks,

    Larry

    http://www.sector67.org
    Madison, WI USA

    Like

  2. @Larry – thanks for getting in touch.

    My first experience of Arduino was with the Duemilanove (2009) and since with the Nano and Uno. All of these boards have built-in serial port emulation over USB.

    With the Due and Nano it’s necessary to install the FTDI drivers to get the serial bit working and with the Uno it seems to be an automatic part of the Uno driver installation.

    So… my setups always go like this:
    1. Plug in the Arduino using a standard USB cable
    2. If I’m using Windows, go into Device Manager, then open the Ports section. Where Arduino is listed it will have the virtual com port in brackets, e.g. Arduino Uno (COM 6)
    …on a Mac or Linux there’s another way to find out which I can’t remember, but the principal is the same.
    3. In my script, be it Python, Perl or Actionscript, plug in that COM port number and it just works as if it was a real COM port, no additional hardware required.

    Hopefully that method will work for you too, but if not please let me know more and we’ll see if we can solve it together.

    Grant

    Like

  3. Grant:

    Thanks for sketching out the FTDI and USB cable details. After I hit send, I realized it was likely something as you described but thanks for sketching out the details for the record and for less experienced Arduinoids…

    Larry

    Like

  4. My python script is giving the Following error:

    Traceback (most recent call last):
    File “C:/Python25/Hellow World.py”, line 5, in
    ser = serial.Serial(‘COM2’, 9600)
    File “C:\Python25\lib\site-packages\serial\serialwin32.py”, line 30, in __init__
    SerialBase.__init__(self, *args, **kwargs)
    File “C:\Python25\lib\site-packages\serial\serialutil.py”, line 260, in __init__
    self.open()
    File “C:\Python25\lib\site-packages\serial\serialwin32.py”, line 56, in open
    raise SerialException(“could not open port %s: %s” % (self.portstr, ctypes.WinError()))
    SerialException: could not open port COM2: [Error 5] Access is denied.
    >>>

    COM2 is the correct port and arduino is plugged in. Any ideas?

    Like

  5. @Peter – thanks for the update. Can I assume from this that you’ve got it working now? If so, congrats!

    One question: is it always necessary for you to run the script immediately after plugging in the Arduino? If so it sounds like some other process on your machine is somehow opening the COM2 port and then keeping it… maybe some system monitor / firewall / AV software? Anyway, I guess if you’ve found a workaround that’s probably good enough.

    Cheers,
    Grant

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.