Introduction: Rainbow Neo Clock

About: Research is what I'm doing when I don't know what I'm doing.

This clock was made as a gift but I was so happy with it that I thought I'd make an instructable for it. The clock uses 2 Neo Pixel Rings from Adafruit Industries as well as the Arduino Pro Mini microcontroller and a DS1307 Real Time Clock (RTC) to keep accurate time. The time can be set when uploading the code to the Arduino should be retained by the RTC even if power is lost, but if like me, you are giving the clock away as a gift to someone who does not know how to program a microcontroller, and if for whatever reason they need to set the time, they can use the two buttons on the back.

The clock also has a lux sensor that measures the ambient light level. The clock will go into "Night Mode" if the lights are turned off. In "Night Mode" the LEDs are dimmed so they do not illuminate the entire room when it's dark; allowing you to sleep.

The clock is powered by a mains supply via a regulated adjustable adapter which I have set on 3.5v. The case was designed in a 3D CAD environment before being converted to a 2D plan for a laser cutter to follow. It is made from several sheets of coloured acrylic which have been laser cutinto rings and then stacked on top of each other to form a rainbow cylinder. The whole thing is held together by 4 self tapping screws, 2 in the front and 2 in the back. There are also 4 other screws that are just for decoration.

How To Tell The Time

The outer ring has 24 LEDs and shows the minutes; it will advance one LED every 2 minutes and 30 seconds (150 seconds). This means that the position of the minutes LED resembles that of a normal clock face i.e. 12 at the top, 6 at the bottom etc.

The inner ring has 12 LEDs and shows the hours, again, 12 at the top 6 at the bottom etc. To make things interesting, the inner ring also changes colour every second with a fast wiping sequence and the outer ring also changes colour every 150 seconds. The video below shows the clock in action :)

Materials

The clock can be split into three main components: the case, the electronics, and the circuit board (PCB). The reason I class the PCB and electronics as separate components is because I etched my own PCB which is a significant task of its own, whereas the Arduino and RTC are already built onto their own PCBs.

ELECTRONICS STUFF

  • Arduino Pro Mini - This can be bought directly from Adafruit (US) or from Cool Components (UK), I used a cheap clone board from china and it works well. You could also use any other Arduino or Flora that is small enough to fit inside the case and has enough pins to accommodate the project.
  • Neo Pixel Rings - Again, these can be bought from Adafruit or Cool Components. You will need a 24 ring and a 12 ring. There is also a 16 ring available but I don't recommend attempting to use the 16 ring to make a triple ring clock as the 12 ring does not fit inside the 16 ring. If you wanted to make a triple ring clock then there is a 60 LED ring available, but it's large and would better be suited to a wall mounted clock.
  • Wires - Lots of wires, in lots of colours!
  • Push Buttons - 2 of these.
  • Resistors - You will need 2x 10k Ohm resistors for the buttons and 1x 470 Ohm for the LEDs
  • PCB - The buttons and resistors are mounted on a PCB. If you etch your own PCBs you will know what you'll need to do that, you can also get your PCB made by a Modela or otherMill or whatever CNC device you have access to. I etched mine so that is the method I will describe further down but I will also include files for machine milling, just be advised that they will be untested.
  • Female DC Barrel Jack Adapter - A useful component that allows many small electronics projects to be powered by the mains without mutilating AC/DC adapters.
  • AC/DC Power adapter - Regulated supplies are preferred but not necessary as the microcontollers have on-board voltage regulators. Having an adjustable adapter allows you to set the voltage close to the working voltage of the microcontroller, (usually 3.3v or 5v) doing this prevents excess voltage being converted to heat and causing the microcontroller to get very hot!

CASING STUFF

  • Coloured Acrylic - I used 6 sheets of A5 size acrylic. Red, Yellow, Green, Blue, Purple and Clear. Each sheet is large enough to cut 2 pieces. Therefore, the total maximum depth of your clock will be the thickness of one sheet x 6 sheets x 2 pieces per sheet. I used 3mm sheets and used only one purple piece in the middle for a nicer look, so my clock has a total depth of 33mm.
  • Self Tapping Screws - I use 8x Number 2 screws (2.2mm) of length 25mm. A I mentioned earlier, the total depth of the clock is 33mm, which is larger than the screws. In order for the screws to hold it together, they must be longer than half the depth of the clock and only 4 screws do the actual holding while the other 4 are cut shorter and are used only for aesthetics. this will be explained in detail later.
  • Laser Cutter - You will need access to a laser cutter. I used the one at my local FabLab in Cockermouth. So, here is a quick shout out to the guys at the BEC FabLab! Thanks Guys!

Step 1: The Case

As mentioned earlier, the case was laser cut from several sheets of coloured acrylic. The Front most piece is clear with a frosted circle that was produced by raster scanning the beam. The next piece is a red ring that has two feet to keep the clock upright, these are also included on the back clear piece, the back piece also has a hole for the power cable. The third piece is yellow and has three internal fixtures to mount a PCB on, they also function to hold the Neo Pixel Rings in place. All the other pieces are identical rings. All pieces have 4 holes in the same position on every ring, these are used by the self tapping screws to hold the rings together. You can download the design below, it includes the front piece, the second piece with feet, the third piece with interior fixtures, and the back piece. Only one middle ring is included! you will have to copy and paste the middle ring so you have the right number of pieces.

It is best to use this file as a reservoir and create a new file for each sheet of acrylic. As mentioned before, an A5 sheet will accommodate two pieces which are not necessarily the same shape.

Assembling the case is pretty easy; it is held together by 4 long self tapping screws and also has 4 short self tapping screws for aesthetic appeal. The cross section drawing shows how these screws, although shorter than the depth of the whole clock, are able to hold it all together by crossing over the middle rings.

Step 2: The PCB

The PCB was made by etching pre-sensitised photosensitive board. I won't get too much into the details of this technique but there is a link to a tutorial below:

PHOTO ETCHING PCB TUTORIAL

The circuit was designed in a program called Fritzing. This is a free program where you can build circuits on breadboards, design circuit diagrams, and design a PCB layout. The program can also export your design for both etching and CNC board production methods. You can download yourself a copy of Fritzing here:

FRITZING

The diagram shown above shows the layout and wiring for the circuit, I have also included my Fritzing files so you may edit the circuit.

The general process of creating the PCB begins by exporting the Fritzing file (.fzz) to a .pdf. This will create several versions of your board. You will need to find the one you need and open it in some image editing software to create a grid of boards, like in the photograph, we do this because often the boards don't come out right so having many to choose from increases our chances of making a good one. Keep the following in mind when choosing which file to edit:

Photo etching uses a copper PCB coated with a photo sensitive layer that resists copper etchant. Light is used to chemically change this layer so it can be removed easily by a developer chemical in order to expose the copper beneath which, in turn is removed by etchant solution. With this in mind, any part of the board that is NOT exposed to light will NOT be removed and will NOT be dissolved in etchant solution.

Once you have made your grid of circuits you will need to print them on a clear acetate sheet. I used 5 Star OHP film which worked nicely provided you print on the correct side. The first print I did was on the wrong side and so the ink did not stick and just made a mess but flipping the film over produced a good image. This will be used to block the light to your board so wherever there is ink, there will be copper on your board. The board is then exposed to a florescent lamp before being bathed in developer solution, finally the board is bathed in an etchant solution. Now you have many copies of your circuit, pick the best one and cut it out! :D

NB: You may have noticed a connecting wire between the Arduino pins 11 and A0, this is in fact a mistake leftover from an earlier design. It does not change the function of the clock if it is left or removed. The photograph of the etched PCB also contains a mistake but I have since fixed it and the diagram is correct.

Step 3: Assembly and Wiring

Hopefully by now you will have etched and cleaned the main circuit board. You will now need to populate with the two push buttons, three resistors, the female barrel jack adapter and a bunch of female headers to mount the Arduino and the RTC. I used female headers to keep the connections semi-permanent, just in case I need to change either the Arduino or RTC. Once you have populated the main circuit board you will have a number of holes left for the Neo Pixel Rings and the Lux sensor.

Firstly, you'll need to assemble the Neo Pixel Rings. The rings are wired to each other by 3 wires; +5V dc (red), Ground (blue), and a Data line (green). It should be clearly marked on the rings which connection is which but I've included a diagram to show how they are wired up. Each ring has three rough edges to mark important LEDs. The middle rough spot will be the top of the ring; or the 12 o' clock position. Make sure these line up for both rings. Once the rings are assembled you should be left with tree wires ready to be connected to the main circuit board. The ground wire can connect directly to the GND pin on the Arduino and the +5V dc wire can connect directly to Vcc pin on the Arduino. The Data wire can also connect directly to a digital output pin but it is recommended that it first passes through a 470 Ohm resistor. This should be built into your main circuit board anyway and should be connected to digital pin 10 on the Arduino.

The lux sensor has three pins that connect to GND, Vcc, and Analogue Pin A3. I used a pre-assembled Lux sensor module as it was super cheap and was just the right size, but feel free to make your own sensor module.

NB: The use of electricians tape is recommended for two instances!! The first is and obvious one; many connections on the underside of boards may be in contact with other components. I use tape to minimise the risk of short circuit, especially around the coin battery of the RTC.

The second instance did not become apparent until after testing the clock. The Arduino has a red LED that lights up when the Arduino is on, this light is enough to trick the Lux sensor into measuring an elevated level of light, to the point that it can not detect when the lights in a room have been switched off!! A simple solution was to place a small square of tape over the LED :)

Step 4: The Code

Programming the Arduino pro mini can be done in a number of ways. I use a USB adapter board that connects the Arduino to my PC by USB cable. In my opinion it is the simplest way to upload a sketch to the arduino.

So first thing first; the disclaimer. I am still relatively new to programming and although I can usually get things to work the way I want them to, there is often a much better way of doing so. With that said, if anyone can make any improvements to the code then I'd be happy to hear about them. Every day is a school day :D

The code offers the user a number of ways to set the time. The first simply takes to PC time and date at the time of compiling the code and sets the RTC to that time. The RTC should be able to keep time accurately from this moment onwards until the coin battery runs out. The second method is essentially the same as the first, only the programmer inputs the desired time manually into the code and that is used instead of the system time. The third method is for users who don't want to, or can not access the code. They can set the time by using the buttons on the back of the clock. This is done by simply checking, each second, if the button is being pressed and then, if the button is indeed being pressed, executing a method for setting the time manually. The problem with this is you may have to hold the button for a whole second to get the clock to register the press; a short press and release may not work every time. Once the set time method is called, the user may use the two buttons on the back of the clock, one button will advance the minutes and the other button will store the minutes position and switch to hours mode so that the first button now advances the hours. Pressing the second button a second time will save the hours position and start the clock running.

The clock keeps time by a series of nested FOR loops. The inner most loop is responsible for counting the seconds. A simple way to do this is to just have arduino delay by 1 second but that will not work for this clock. Each second and every 150 seconds (2.5 mins) there is a short animation which takes some time. You could account for this time and then simply have the arduino delay the rest to make the total delay up to one second, but again this leads to time creep as the clock is a fraction of second off each second. The way this clock works is by checking the RTC and simply waiting until it has advanced by one second without using any delays. Again, there are better ways to keep time such as checking the RTC for all time information (i.e. hours mins and seconds) and just have the neo pixel rings display accordingly. If anyone wants to redesign the code to be more efficient and accurate then I'd be happy to hear from them.

As for the automatic dimming in dark rooms, the lux sensor measures the ambient light every second and if it falls below a set value (which you may wish to change) it will change the global brightness of the LEDs. The LED brightness is set by a number between 0 and 255, normally I have it on 30 during the day and 1 at night. But I soon found that even set to 1 it was too bright for me to sleep (I like total darkness when sleeping) so I set it to 0. The LEDs dim until they appear off, but the clock continues to count. There is also an LED mounted on the Arduino itself which can be bright enough to confuse the sensor, this was overcome by sticking a small square of insulating tape over the LED.

There are also some unused methods that are for some different animation effects that look cool, in case you felt like experimenting with the way the clock looks.

If you don't care about the code and just want to build a clock, then all you have to do is decide how you want to set the time and upload this code to your arduino and away you go.

Step 5: Power Supply

The clock is powered by a mains supply which is converted to 3.5V by an adapter, this then plugs into a female barrel adapter of the appropriate size and powers the Arduino via the RAW input pin. Setting the adapter to 5V also works if you prefer. The Arduino mini pro has a built in voltage regulator on the RAW pin and can convert an input of up to 12V, however excess energy is converted to heat so it tends to get rather hot when the input voltage is so high.

And that's about it :D

As mentioned earlier, the code needs work and if anyone has any improvements please feel free to edit the code, I'm eager to learn. There are also other improvements that could be made, the Arduino has many additional pins that could be used for a speaker for an alarm etc. So have fun with it :D

Rainbow Contest

Third Prize in the
Rainbow Contest

Bedroom Contest

Participated in the
Bedroom Contest