TheSUN, Arduino Powered Design Wall Clock
by SerialQ in Circuits > Clocks
8006 Views, 92 Favorites, 0 Comments
TheSUN, Arduino Powered Design Wall Clock
Hi again Instructables-folks! :-P
Because of shipping-problems I wasn´t able to continue my ABTW Project so I decided to show you another, my newest creation.
I think many of us, like me, like those nice addressable LED Stripes (also called NEOPIXEL LED). You can get them from ADAFRUIT. Other vendors will also provide similar products. There is a library available on ADAFRUITS - GitHub (click me) including some sample code.
So coding should be straight-forward...
I saw those NEOPIXELS an thought, what the h... can I do with those shiny little things.
- A LED-matrix Display? -> To complicated and I don´t use it (at the moment)
- X-Mas Lighting? -> It fits the season but it would be cheaper to buy one :-P
- a clock? -> Why not! But it should be stylish and unconventional
So, let´s make a wall clock.
If we have a close look at our wrist watch (if you have an analog like me) we will notice that we have 12 hours and 60 minutes (hopefully). That will mean, that we need 60 addressable LED´s, phu!
If we take a stripe with 60 LED´s / meter we will get a diameter of ~318mm (radius = scope /(2*Π)) that´s definitely too big.
The truth is, if you ask someone for the time, no one will say it is 2 minutes past 3! You will get "It´s 5 past 3" as an answer.
So why shouldn´t we scale everything down to 5min steps? For that we will only need 12 LEDs which means we get a diameter of 63.6mm. We are also able to differentiate hours and minutes by giving them a separate colour.
We will also be able to provide the "missing" single minute steps with an additional Strip of 4 LEDs(or single addressable LED.
THAT`S THE PLAN!
Let´s have a look how I did everything.
As always I will provide a list/bill of materials and instructions on how to build it.
If you think, only Swiss people can make cool clocks, let´s proof you´re wrong (sorry Switzerland :-P)
Design & Choice of Materials
Design:
If we have a close look at our analog watch/clock again we see that the circle is divided into 12 * 30° steps we know, that we need 63.6mm for the LED-Strip. So it should be possible to align the strip around a tube somehow. I decided to use acrylic glass, because it looks nice and it is possible to encapsulate the LED light into it and at every flaw in the glass some light scattering will happen. So, let´s say: more impurities will lead to more light scattering! That´s exactly what we want. So feel free to grab your engraving tools and be creative :-)
If you refer to my BoM-list and the name i gave to the clock, I have chosen a sun like design.
I got all the acrylic parts from a German seller on E-Bay (link provided in the BoM).
For my design you will need:
- acrylic ground plate, transparent thickness = 6mm, diameter = 300mm
- acrylic middle plate, transparent thickness = 3mm, diameter = 150mm
- acrylic front plate, satin, thickness = 3mm, diameter = 90mm
- acrylic tube, transparent, outer diameter = 64mm (will mean we have to tweak a little with the LED strip)
- acrylic rod, transparent, diameter = 5mm (this will be our beams); There are also acrylic rods around with bubbles inside, I recommend them but i don´t have them around.
- acrylic glue
Electronics (refer to the Fritzing-files):
- Arduino mini (or similar)
- 1 addressable LED Strip (12 LEDs for hour and 5min steps)
- 4 addressable LEDs (single minutes)
- 2 330Ohm Resistors
- 1 1000µF Capacitor
- 1 powersupply (5V/500mA)
- an RTC DS-1307 (optional!)
- Bluetooth module (optional! yes you can set the time via BT and an Android Smartphone)
If you ask yourself why i have MAX485 chips on my BoM. The answer is, that I want to syncronize the clock with the home automation system I´m about to make (never ever have to set a clock for daylight-saving again :-P).
I will describe that in my blog in the next couple of weeks/month.
As you noticed, I will also try to get the clock off-grid with some solar panels and a LiPo, but I don´t cover that in this Instructable feel free to try it yourself.
Prepare the Acrylic Parts
The tools:
First of all it is really helpful if you print the DWG plan i added in the scale 1:1.
This will help you to align all the parts and will serve you as a drilling plan.
further you will need:
- hobbyknife
- miter gauge
- hacksaw
- clamps
- hand drill
- can drill, diameter 65mm
- a set of metal drills
- a small metal file
- acrylic glue
Let´s start:
Take the ground plate and align it on the plan, so you can get the center of the circle. Now take your hand drill with the can drill mounted onto it and drill (very slow! not to much pressure!) a hole in the center of the ground plate, the outer circle should be ~2-3mm deep. This is to sink the LED strip into the ground plate (LED strip ~10mm wide, beams only 5mm in diameter) and to align them with the beams (refer to picture 1).
Now we need the hacksaw, the miter gauge and the acrylic tube. Just cut it into pieces i decided to make the housing (tube) 40mm long (picture 2). Now grab the hacksaw again and make a little rabbet on one side of the tube, make it smooth with the metal file. That´s where the wires will come out ;-) (refer to picture 3)
Time for some glue...
Take the middle plate (d=150mm) and the front plate (the satinated one).
align them on the plan again, put some glue on the center of the middle plate, align the front plate and wait till the glue is slightly hardened. The glue i used is light hardening and it can take up to 2-3h, so mybe you want to use a clamp... (picture 3 and 4)
Do the same for gluing the tube onto the ground plate, make sure the rabbet is facing to the plate and is alligned somewhere where you want the first LED (12 o´clock) to be.
Wait till it is hardened!
We can now align the 2 parts (bookmatched) onto the plan an drill our 4 single minute holes (5mm in diameter or the diameter of the LED you have chosen; drill it slow with not too much pressure). Drill about 8-9mm deep. Be careful, the satinated plate is very brittle and can brake if you drill to deep.
You can now glue them together or you decide, like me to cut a threat into the ground plate and attach it with a screw.
Again, wait till glue has hardened.
Now align and glue the beams onto the ground plate. (picture 6)
Guess what... wait till the glue has hardened :-)
Let´s proceed to the electronics...
Downloads
Electronics
The tools:
- soldering iron
- solderwire
- hobby knife
- a small piece of prototyping PCB
- enamelled wire or any other wire you prefer
- hot glue
I strated with the single LEDs.
If you use enamelled wire don´t forget to scrape of the lacquer before soldering. You can use a hobby knife for that.
Wire them up, you can refer to the picture with the pinout on flikto.de. Note that DOUT goes to DIN on the next LED! (see picture 2)
After that you can cut the LED strip into 4 elements each with 3 LEDs. Remember, we have 63.6mm LED Strip and 64mm outer diameter of the tube so we need some "extra length to align it precisely to the beams. Wire it up with enamelled wire like in picture 4.
I made a little proto PCB which will serve as a "power harness" and will contain the components for the LED Strips (the two 330Ohm Resistors and the 1000µF Capacitor, picture 7). Refer to the Fritzing Image for that.
Now mount the Strip around the tube, allign the LEDs to the beams. The first Pixel matches 12 o´clock. If you have turned around your housing, don´t forget that everything is mirrored. Proceed counter clockwise! Use some hot glue to attach it to the tube. A small drop for every segment will do it!
You can do the same for the single LEDs (eventually mirrored), just add some hot glue and press them into the predrilled holes.
Don´t wire the Arduino yet, we will use the hardware-serial for the BT connection, so first check the next steps where i describe the software.
Code
You can now load the sketch to the Arduino. You´re also able to wire the LED strips now. Don´t connect the BT Module!!! We first want to have a look at the code, you should know where you can tweak several things...
Download the Arduino IDE and the Librarys.
Arduino IDE, AdafruitNeoPixel, Time, DS1307RTC
Install the IDE and put the librarys into the library-folder.
Open the attached INO file and upload it to your arduino. The code described here is the same but with additional comments! If you have done everything right, you can now see the "bootanimation". It is possible to set the time over the serialmonitor. Just type @"hour"/"min"/"sec" eg. @10/33/00 (10:33).
Feel free to play with the code...
Here ill give you a brief description of the Code (Setup without RTC!)
DEFINITIONS:
#define PIN 6 //Hour LED Strip
#define MINPIN 5 //Singelminute LED
#define NUMPIXELS 12 //Number of Pixels for hour
#define MINNUMPIXELS 4 //Number of Pixels for single minute
#define BAUDRATE 115200 //Baudrate, should match the baudrate of BT Module
#define utch '@' //start BYTE of TimeSync
int timeset = 0; //flag to store if the time was set after boot
int delayval = 20; //delay for fading animation
int clocktimer = 10000; //time refresh
int timebright = 250; //brightness of hour Strip
int mtimebright = 50; //brightness of singelmin
int initialize = 0; //flag to call the clearpixels function after boot
int ahour;
int oldahour = 0; // store prev. hour
int aminute;
int oldamin = 0; //stores the previous minute for refresh
int asecond;
int aday;
int amonth;
int ayear;
int mmin;
tmElements_t tm;
//Setup for the 2 NeoPixel LED arrays ( NAME = TYPE(NUMBER OF PIXELS, WHICH PIN, FORMAT RGB OR GRB, FREQ); Refer to the Adafruit guide for more information.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel minpixels = Adafruit_NeoPixel(MINNUMPIXELS, MINPIN, NEO_RGB + NEO_KHZ800);
SETUP:
void setup() {
Serial.begin(BAUDRATE);
Wire.begin();
// Initialice the strips, all OFF
pixels.begin();
minpixels.begin();
pixels.show();
minpixels.show();
//Make a little animation
Serial.println("SUNRISE");
sunrise();
delay(1000);
Serial.println("SUNSET");
sunset();
pixels.show();
Serial.println("READY");
}
LOOP:
void loop() {
// check for timesync
while (Serial.available() >0){
char c = Serial.read();
if(c == utch) //if there is a @ on the line, read the coming bytes / ints
{
readtime();
}
}
// initialice the LEDs, clear boot animation
if(initialize == 0){
clearpixels();
initialize = 1;
}
ahour = hour();
aminute = minute();
if(timeset == 1 || timeset == 0) // here you can check if the Time was set, you can stop the program here if Timeset = FALSE, just remove "|| timeset == 0" !
{
if(oldamin < aminute || oldahour < ahour) //check if the time has changed. TRUE = refresh -> set all to OFF, display new time
{
clearpixels();
ClockDisplay();
}
}
}
Display the Clock:
void ClockDisplay()
{
oldahour = ahour;
oldamin = aminute;
int xhour, xmin;
if (ahour >= 12){
xhour = ahour-12; //we only have 12 LEDs for 24h display
}
else {
xhour = ahour;
}
//scale it into 5min steps
xmin = (aminute / 5);
if(oldamin < aminute)
{
oldamin = aminute;
clearpixels();
}
//take the rest of the division dor the singelmin LED
mmin = (aminute % 5); // modulo operator eg. 24 % 5 = 4! very useful :-P
pixels.setBrightness(timebright);
pixels.setPixelColor(xmin, pixels.Color(5,125,255)); // you can change the colours here! play around!
pixels.setPixelColor(xhour, pixels.Color(255,50,0));
pixels.show();
//display the singel mins
for (int m=0; m
minpixels.setBrightness(mtimebright);
minpixels.setPixelColor(m, pixels.Color(255,255,0));
minpixels.show();
}
}
Read and process TIMEinformation from Serial
void readtime() // if we already got the leading "@" process the coming data and store the time for the TIME Lib
{
ahour = Serial.parseInt();
aminute = Serial.parseInt();
asecond = Serial.parseInt();
aday = Serial.parseInt();
amonth = Serial.parseInt();
ayear = Serial.parseInt();
Serial.println("TIMESET");
Serial.print(ahour);
Serial.print(" : ");
Serial.println(aminute);
setTime(ahour,aminute,asecond,aday,amonth,ayear);
}
Clear all!
void clearpixels() // set every single PIXEL to off to refresh the display
{
pixels.begin();
minpixels.begin();
for(int i=0;ipixels.setPixelColor(i, pixels.Color(0,0,0));
minpixels.setPixelColor(i, pixels.Color(0,0,0));
pixels.show();
minpixels.show();
}
}
The Android APP and BT Connection
If you were successful with the previous steps, you can now wire up your BT Module. (i hope you made sure, that the baudrates match). don´t forget to cross TX & RX lines :-)
Download and install the app, pair with your BT dongle, start the app, connect to the dongle and Sync the time with your mobile. The APP basically does the same like we did before. It just sends @hh/mm/ss/dd/mm/YYYY generated from its systemtime.
I also provided the APPInventor AIA File and an explanation on the next step (for those who are interested).
Downloads
APPInventor
APP Inventor is pretty easy to use and worth the effort for such a simple program.
If you make a new project you will find your self at the DESIGNER screen. (picture 1)
This is where we add tables, buttons, sensors and other elements for further use.
In our case we need:
- a table (to allign all elements)
- a listpicker (for selection of the BT device we connect to)
- a button (to fire the TIME over BT)
- some labels (display the actual time and date)
- the clock sensor (refresh the time)
- the bluetooth client sensor (connectivity)
Adding them is just as easy as drag & drop!
On Picture 2 you can see an overview of the "APP" in the BLOCKS screen. Well, that´s basically where all the "magic" happens.
On the top I created some variables to store the Time and Date.
The first block on the upper left will initialize the listpicker element with the list of paired BT devices.
With the second block we decide what to do with the previously picked element. Well, we want to connect to it.
If you have a close look at the next Block, you can see, that we generate, if the BT status "is connected", the BT message. It´s the same we typed into the SerialMonitor before.
The last block on the left will provide us the leading zeroes to display the time (eg. 01:08).
On the right side you can find our last block, that´s where we use the clock element.
Here we update the variables and merge them with the digits procedure, this will happen every 1000ms (default setting, change it in the designer mode) and display the updated values with the label.
That´s just a brief description, but APPInventor is really as easy as that :-)
Maybe there is someone in the community who wants to write a software for iOS or WindowsPhone. (would be great)
I hope you liked my Instructable!
Have fun with your new wall clock!
Maybe you want to gift it to someone you love (Its X-Mas season) :-)
And if there are any questions, feel free to ask me!
Best regards and Merry X-Mas.