Space Invaders Clock (on a Budget!)




Introduction: Space Invaders Clock (on a Budget!)

About: By day I am an electronic engineer for a certification and approvals company, by night I am an avid technology hobbyist and DIY'er. I enjoy learning how things work, and sharing my learning experiences with ot…

Recently I saw a cool build by GeckoDiode and I immediately wanted to build it myself. The Instructable is Space Invaders Desktop Clock and I recommend you have a look at it after reading this.

The project was almost solely built out of parts sourced from Adafruit with a 3D printed enclosure, and laser cut facia. Adding everything up the cost of the build becomes very costly! (around £100 or more). The problem is if you don't own a 3D printer you have to pay to get your model printed, or buy an ugly enclosure off ebay which is often just a little too small, too narrow, to short, or the opposite.

Most of my builds have to be done on a hobbyist budget and enclosures always end up being the most expensive part. So I decided to build the same clock but on a decent budget.

If you enjoy looking at weird clocks, check out my Steampunk Voltmeter Clock, which uses the same build materials for the enclosure :-)

Step 1: Gather Parts

To make this project you will need the following. Keep in mind with the materials for the enclosure you will have ALOT of left-overs which you can use in other projects (which makes the cost of future builds even cheaper). I have uploaded PDF's of the stuff you need if you want to check price etc on ebay.

Tools (I assume you will have these already)

  • Soldering iron
  • Solder
  • Solder pump (if you make a mistake and need to remove solder)
  • Hot glue gun
  • Hot glue sticks
  • Craft knife (a.k.a. stanley knife)
  • Ruler / measuring tape / Vernier caliper
  • Cordless drill + drill bits (1 mm to 13 mm)
  • Rotary multi-tool with cutting disc (a.k.a. Dremel)
  • Cleaning fluid like Isopropyl-alcohol (cheap aftershave works too)
  • Safety mask (used when spray painting)

Electronics (Cost of electronics = £13.05)

Some of these I had for free. Old electronic toys have these nice Mylar speakers inside if you take them apart. While you're there you can probably get a DC barrel and a push button too.

  • Dupont / Jumper cables - £0.99
  • DS1307 Real time clock module - £0.99 (I'd recommend getting DS3231 instead where available)
  • Arduino nano + usb cable - £2.23
  • 8 Ohm Mylar speaker - £0.99
  • SPST momentary push button - £1.49
  • 5.5mm DC barrel socket - £1.26
  • 5v, 0.5A DC power supply - £2.83
  • MAX7219 Dot matrix display - £3.76

Enclosure (Cost of enclosure materials = £17.19)

  • 60mm square drain pipe - £5.99 (you will have ALOT of this left over for more projects)
  • Black spray paint - £4.85
  • Black PVC (foamboard) - £2.99
  • Super glue - £0.99
  • 60mm end caps - £2.37

Total cost = £30.24 :-) of today this is the equivalent of 38 USD for any international readers.

I enjoy working with the PVC square pipe. They are easy to drill, cut, paint, and I used one for my Steampunk clock.

Step 2: Prepare You Drain Pipe

Mark out where you want to put things

This was so easy. I didn't use anything fancy. First I cut the 2.5 m length down to a reasonable size for my bench at home (about 30 cm) with a hack saw. I later cut this down with a dremel to make the edges nice and straight. Then I rested the components on the surface of the pipe and used a permanent market to mark where I wanted to drill and cut. I traced around the outside of the LED matrix, and used a rotrary multi-tool to cut a square hole for it to fit flush. I used a digital caliper to measure the diameter of the push button and DC barrel to cut the correct size holes in the back and top.

Cut a bezel

I have loads of PVC foam board laying around from previous projects. They are great for mounting circuits into enclosures, using it to mixing epoxy together on it, and making other bits and bobs. Take a A4 or A5 size piece and cut a square 5 mm surround or bezel to frame the LED matrix. This will hide any wonky endges you made when cutting the square hole for the matrix. For this I drew a small template on Inkscape and printed it out (SVG File attached). I then taped it down with masking tape to the foamboard and carefully cut around it with a craft knife. It's tricky to get right, I recommend cutting the inside first then the outside.

Paint everything

Once all the holes are drilled and cut, remove any burred edges. Clean the surfaces with some alcohol wipes to remove any dust or pollution (or some cheap aftershave if you don't have any IPA). Try and spray in a well ventilated area and use a mask where possible. I did this outside with some cardboard on the floor but it's not ideal, even a small breeze can cause paint to fly back into your face. Be careful and wear protective equipment where possible.

Spray the pipe, bezel, and end caps so they are all the same type of black, then leave to dry for a few hours.

Step 3: Program the Arduino

Some information about the code

Credit to GeckoDiode as I have taken his code and modified it to work with the MAX7219 Chip. The Adafruit version uses I2C bus and the MAX uses the SPI bus. For this I used the MaxMatrix library, which I downloaded and installed into the Arduino IDE. If you want to learn more about MaxMatrix and how the LED matrix works in principal there is a very short tutorial on The LED matrix is solely made up of a single colour of LED's rather than having a multi-coloured display.

One frustration I had is that there is NO clear definitions of what the functions are for the library are and what arguments need to be passed into each. Luckily I was able to find out what did what by trial and error and in the end it wasn't too difficult to get it to work properly. The first thing to understand is that you have to define how many 8x8 modules are in your matrix. In my code this is stored in a integer called "modules" like this:

"int modules = 4;"

This is the NUMBER of 8x8 modules you have linked together in your display. Not the number of LED's or what pin you are using the send data.The next thing to remember is that if your "sprite" or whatever covers all four matrices then the byte array needs to be defined like this:

"byte text_start_bmp[] = {32, 8,...*some byte data*...};"

The numbers indicate the amount of rows and columns in the matrix. On this occasion the byte named "text_start_bmp" is displayed over 32 columns and 8 rows. The numbers are only displayed on one single 8x8 matrix so the minute number 10 looks like this:

"byte minute_ten_bmp[] = {8, 8,...*some byte data*...};"

The invaders cover two matrices so the byte will be given 16,8 in the byte data.

The other thing that caught me out was the positioning of the sprite data. You can ask the Arduino to display the sprite in a different X/Y position on the matrix from the default home position. The code looks like this for the minute zero:

"matrix.writeSprite(8, 0, minute_zero_bmp);"

One number is X adjustment and another is Y. Can't remember which one is which now, but if you want to nudge the sprite up or down by 1 row or column you simply increment the number positive or minus. Simple enough for 8x8 matrix but when your sprite covers more than one matrix you have to set the home position accordingly. The "POP" sprite is shown below:

"matrix.writeSprite(16, 0, invader_pop_bmp);"

Notice now how the home position is 16 not 8? Here the code is indicating the the sprite is displayed from left to right from position row/column 16. It considers two 8x8 displays to be a single 16x8 display even though there is 4! Therefore it is important to think about how many displays the sprite will be displayed across and sizing each sprite's byte array accordingly. Otherwise you will have some very interesting sprites!

DS1307 RTC

Althought the DS1307 works fine with the Adafruit RTClib.h library, you cannot manually set the time which is just a pain. I just went with this because it meant less code to change. The DS1307 sets the time using the time and date the code was compiled from your computers time. Instead learn how to use the DS3231 library and set it once for one or two minutes ahead in the future. It also has less "drift" so it keeps time better over time. Both modules use the I2C bus and I believe the DS3231 can be used with the RTClib.h if you care to continue using it.

Upload the code

Once you are happy with the code upload it to the Arduino. I have attached my Arduino sketch for your consideration.

Step 4: Assembling Electronics

Whilst uploading the code I would recommend having the electronics assembled with dupont/jumper wires on a breadboard first so when you upload the code you know everything works as intended. This allows you to iron out any issues with displaying the sprites etc before you start gluing and sticking. In my code you can see I am using digital pins 4, 5, 6, 7, 9, but you can change these if necessary. You may need to solder cables onto the button, DC jack, and Speaker but the majority should be easy push fit style connectors.

Once you are happy the electronics work as intended you should consider soldering the connections. You can do this with copper stripboard/veroboard, but for the small amount of components you can solder directly to the pins of the Arduino. It will look like a rats nest but nobody will see inside the enclosure once it is assembled anyway, just make sure that all metallic parts are segregated, you don't want anything shorting out in the case.

I have made the push button work when the "mainButton" pin is pulled low. I found the Arduino was recognising false push button pressed when floating electronics settle on it. Using a 10K pulldown resistor on the push button and setting the pin to "INPUT_PULLUP" solved that problem for me.

Attached is the schematic in PDF and PNG so you know where to connect the pins.

Step 5: Mount the Electronics and Close Up

For my clock I mounted the electronics using hot glue, but be careful not to apply too much (electronics do not like being heated up for too long). I used a small drop of super glue dotted around the bezel and pressed it against the front. I finished off the enclosure by pushing in the end caps at each end. Of course you can glue the end caps to completely enclose the assembly, but I left one side of mine open so I can still access the USB port of the arduino to reset the date and time in the future.

Step 6: Enjoy

Overall I'm pleased with the way this came out, considering it just some gutter pipe and spray paint. I hope you like it and let me know if you can think of any cool upgrades that can be added. I would be interested to know if anyone can make this cheaper or if there is another thrifty way of making an enclosure I can try in my next project.

Microcontroller Contest

Participated in the
Microcontroller Contest

Be the First to Share


    • Game Design: Student Design Challenge

      Game Design: Student Design Challenge
    • Make It Bridge

      Make It Bridge
    • For the Home Contest

      For the Home Contest



    4 years ago

    hello i am new in programming in arduino i wanted saber in which part i establish the time.


    Reply 4 years ago

    Lol, I have no idea what you mean. Like a light saber that tells the time?


    Reply 4 years ago

    I think he was probably asking how to set the time.


    Reply 4 years ago

    The RTC1307 library doesn't allow you to set the time manually (as I mentioned in the instructable) instead the time that is set is the time that is timestamped onto the arduino Sketch when it is uploaded. So far I cannot see any way around this unless you use the DS3231 module.


    Reply 4 years ago

    Yes I was just trying to establish what the original comment was trying to ascertain! You're right the ds3231 is probably the answer! ;-)

    Alex Peru
    Alex Peru

    4 years ago

    Nice work.
    I tried to do it but I did not succeed.
    Please, you can put the modified max7219 library.
    Thank you very much in advance


    Reply 4 years ago

    Nope sorry. You will either have to use the MaxMatrix library, or learn how to use a different library.


    4 years ago

    Ahh wow that takes me back! The original Space Invader clock by GeckoDiode was one of my first instructables that I wanted to make.... I have all the parts... but yet to make it myself. (still!!) I remember looking at his case that you could "3D print".... what the heck is a 3D print... lol How times have changed! His clock is one of many projects I have on the go.

    (Your) Great project though, and a great idea to use the plentiful MAX7219 matrix boards, well done!! Looks great!


    Reply 4 years ago

    Thanks mate, you should just sit down this weekend and start it. I really enjoyed making it. Hardest part for any of my projects is finding a decent enclosure for a decent price. Glad you enjoyed it :-)


    Question 4 years ago on Step 4

    Hi Jamie,

    I think I spotted an error in your schematic: the push-button cannot be connected on both sides to GROUND as shown. Will you correct it?




    Answer 4 years ago

    Well spotted Nick, I got my digital pins and physical pin numbers mixed up! I will amend this tonight, thanks for pointing it out. Hope you like the instructable :-)