Pinball Clock

The time is 12:10 and 31 seconds

Now that we finally moved house we have space for all the extra things. The new house has a large extension which allowed us to turn the old dining room into a bit of a games room. We're now the proud owners of a Stargate pinball machine which we love but it's very possible to loose track of time while we're playing. I decided that we needed a clock in the room and it would be cool if it was in keeping with the pinball theme. I dug out an old dot matrix display and a wemos D1 wifi controller so that it can retrieve the time from the internet without the need to set it up.

The screen is an 8x32 red LED dot matrix, controlled by the MAX7219 chip. The display uses SPI to connect to a Wemos D1 microcontroller, this means there's only three data lines that need to be wired between the two devices. Power and Ground are also connected to the Wemos board which allows the whole thing to be powered from the USB connection, this is useful for programming and during normal operation the clock is connected to a USB wall socket.

The enclosure is made from laser cut poplar plywood coloured black once assembled. The design is a very simple minimal box that increases the screen size by 3mm on each side. I wanted it to be as unobtrusive as possible while sat on the top of the pinball machine. There's a simple hole in the back large enough to pass the USB connection through it. I possibly should have mounted it closer to the hole but it's much easier to disconnect it from the wall instead. The box is glued together which doesn't allow access but it's such a simple design that it shouldn't need to be accessed in the future. (svg here)

I was keen to replicate the style of the score increasing during a game of pinball, the pinball score only increases in multiples of ten so I added a zero onto the end of the second counter. On our pinball machine, most targets increase the score in thousands with big shots giving millions so it make sense to use those as the hours minutes respectively. This means the left most characters represent the actual time hh,mm. To keep the formatting correct there has to be an additional zero inserted between the minutes and seconds. The hh.mm0.ss0 format initially looks a bit confusing but if you concentrate on the first four characters it's really easy to read. Due to the screen size I had to opt for 3x5 pixel characters to get all the information onto the 32 pixel width

The device was programmed Arduino environment using several existing libraries. (source code here)

The ESP8266WiFi library allows the device to connect to an existing wifi network.

I used the core time library for the ESP8266 because it provides a method for connecting to the Network Time Protocol. This allows the device to retrieve the correct time from the internet but more specifically if allows you to compensate for British summer time, this means it should move back and forward as required over the summer.

The U8glib library is a graphics library for monochrome displays, it provides all the useful functions for writing fonts and graphic items to the display.

Finally I use the FastLED library because it has an incredibly easy to use macro function that is called at specific time intervals. No messing around with blocking delays or the millis() function.

Once initialised the main loop of the program simply checks on the time and updates the display at one second intervals. The majority of the code for this program is about setting up the Wifi and NTP server and confirming that they are connected before progressing to the main loop.


Popular posts from this blog

Wiring the Ruida Controller

Rainbow Puzzle Box