Saturday, October 1, 2016

Nuw: the resistor color code clock

I wanted to make a clock. Clocks can be cool. However the internet is filled with projects about making clocks, so I wanted to make something special. And that is how Nuw originated.

Nuw is an abbrevation of Nerds Ultimate Watch. It is ofcourse presumptuous to use such a name but hey I invented it so I can name it whatever I want.

I had this stupid idea about making a clock that displays the time not as usual in figures but in resistor colour codes. Let me explain.

Every maker/tinkerer knows about resistor codes. Resistors don't have figures printed on them that tell the value. No their value is expressed in colour codes. And these codes are an international standard. So let's look at the colours that represent the figures.




The real resistor colour chart is a bit more complicated as I needed. I just need the colors with the accompanying figures.

Now let us look at time.




We display the time as 2 figures for the hours, 2 figures for the minutes and 2 figures for the seconds.

Well that can easily be interpreted.
Looking at the table 12.30 would translate into Brown, Red, Orange and Black.

Lets take another example. 15.47 would translate in Brown, Green, Yellow and Purple.

Sounds easy.

To display hours, minutes and seconds I would need 6 RGB leds. As each led needs 3 pins for the colour this would add up to 18 pins on a processor. That would rule out an Arduino. I would need an Atmega2560 for controlling all these pins. And that would be a total overkill. So lets skip the seconds and keep it to the hours and minutes.

To achieve this I would need 4 RGB leds. As each led has 3 pins for choosing colour I would need 12 pins on a processor. I would also need at least 2 pins for attaching switches for setting the time. One switch for setting the minutes and another one for setting the hours. So that sums up to at least 14 pins. This means I should be using an Arduino. And I did not want to use an entire Arduino for just a clock. So I could take an Atmega 328, program it with an Arduino board and put it in a dedicated pcb. That should work but I did not like the idea.

I decided to take a different approach.

If I was to use Neopixels (WS2812 led's)  I just needed 1 datapin. Using two buttons for setting the time would add 2 datapins. That sums up to 3 pins on a processor. So I could use an Attiny85 !!! Now we're getting somewhere.

I herebye give you the schematics and the breadboard layout made with Fritzing
For clarity of the schematics I let the power lines to the neopixels out. They speak for themselves.





So I build a prototype on a breadboard and started coding.

Coding was actually easier as I expected.



I used the Adafruit Neopixel library and the Time library.

The code starts with initialising the libraries and then declares an array in which the colors that correspond with the figures are declared.

The function setresval() sets the resistor color code to the neopixels.
The first Neopixel should display the values 0,1 or 2
The second neopixel should display the values 0 to 9. These take care of the hours.
The third Neopixel should display the values 0,1,2,3,4 and 5
And the last neopixel should again display all the values from 0 to 9. These take care of the minutes.

The Time.h library takes care of the hard work. It automatically puts the hours forward if the minutes reach 59 and resets the clock to 00:00 if 24 hours have past.

At the bottom in the code is a function called keyhourl().
This code watches if a button (toets1 or toets2) is pressed. If that is the case it looks which button was pressed and accordingly add's 1 to the hours or 1 to the minutes. This ables us to set the time.
The neat part is that if you keep the button pressed the code will cycle through all values, so you do not have to push the button like a madman to get at for example 55 minutes.

The code works flawlessly.

The casing.

I first put the prototype on stripboard. That gave me an idea about how big the pcb would be. I soldered the switches on a separate pcb so I could arrange to have them at the side of my casing.

I would have loved to make a wristwatch however I do not own (or can buy easily) those nice Lipo batteries. So I had to use AAA batteries.

As the Attiny is not voltage critical, and neither are the Neopixels, I could use 3 AAA batteries giving me 4.5 volts which is sufficient.



Using Tinkercad I designed my casing.
You can find the design here:  https://www.tinkercad.com/things/6RO5IBVzPAn-nuwcase01
And the design for the lid here:  https://www.tinkercad.com/things/gOw2PweYORx-lid-for-nuwcase01

As at the time I was using my old Prusa I2 which is not as accurate as my new Beagle I designed the case without holes for the neopixels and switches. So I made the case solid and used a drill to make the holes.

The pictures below shows you how it is all put together.









It really works.

After getting used to it, it actually is quite easy to set the time.





I took the clock several times to my work and already have some collegues who yell at me: "Hey Luc it is already brown-green o'clock, time for a coffee break !!!"

The 3 AAA batteries supply enough current to let the clock work for about 8 hour.

A small flaw.

Well not exactly a flaw but a shortcoming. It is a bit difficult to distinguish brown, red and orange. This is due to the way colours are mixed in RGB-leds. If anyone has a better colour code for brown, red and orange please mail me the details.

Room for improvement ???

Yes there always is.

Small batteries so I could turn it into a real wristwatch would be nice.

Or I could attach a power supply to it. Should be easy. Any 5 volt supply (like a phone charger) could do the job.

Another Idea is to attach a RTC (Real Time Clock) so it would no longer be necessary to set the time.

When using a power-supply a blue-tooth connection with an Android Phone could easily be made for mail and sms alerts etc. It could even automatically set the time.

Replacing the Attiny with an ESP8266 is not a very big problem. However that would certainly need a power supply in stead of batteries. But then the ESP could fetch the right time automatically.

Oh and then this:

When you build this project and have it on your desk and people start complaining that it is to difficult to read the clock just tell them that this clock lets them contemplate on the concept of time.

This was a really fun project to figure out, design and build.

Now as usual the only thing that rests me is to give you the source code and the STL files so you can print one for yourself. You can find these on Github with the following link:


https://github.com/Lucvolders/NUW

Till next time.
Have fun

Luc Volders