Introduction: Clockception - How to Build a Clock Made From Clocks!
Hi All! This is my submission for the 2020 First Time Author Contest! If you like this project, I'd greatly appreciate your vote :) Thanks!
This instructable will guide you through the process for building a clock made of clocks! I've cleverly named it, "Clockception". I know, very original.
It is actually a replica of the ClockClock designed and built by Humans Since 1982. I came across the clock a few years ago and I was instantly mesmerized by its synchronized movement and minimalistic beauty. If you haven't seen it, take a look at their site as it truly is a work of art.
That said, bespoke art usually comes at a price. In this case, $6k - $11k depending on the finish.. If you have the means, I'd highly recommend you pick one up. But if you're like me and don't have a spare $6k laying around, then you're in luck because today I'm going to show you how to build a simpler version of one for around $200 with some basic tools and a 3D printer!
Note: The saying, "you get what you pay for" holds true in this case as my design isn't able to make the complex synchronized moments that the original does. But I still think its pretty cool, especially since you'll be able to say you made it!
Step 1: Review Design
The first thing to work out in the design was the motion.
I believe the real version of the clock uses concentric dual shaft stepper motors to move the hands, similar to what was used in automotive instrument clusters to move the needles before everything went digital. With a bit of research, I found an off-the-shelf motor that seemed like it could do the job, but they were fairly expensive and had a very long lead time (1m +). Not going to work.
Servos on the other hand are cheap, readily available, and very easy to program. Solution found.
After a bit of time in CAD, I came up with a design. The plan was to make 24 little clocks where the hands of each clock could be independently controlled with two servo motors, mount those clocks onto a board in an 8x3 grid, and write a bit of code to control the movements so the hands make numbers. Mission plan complete.
With that sorted, I shifted focus to mapping out the positions of the hands for each number they needed to form.
This involved scouring the internet for images & videos of the ClockClock in action. I found images for some of the numbers but I came up dry for a good amount as well. After some frustration, a light from above shined down and I came across a site where someone made a digital version of the ClockClock and had an image of all the positions. Score!! Credit to Manuel at manu.ninja. Check out his blog post with the project! Very cool stuff!
Using this, I mapped the position and movements each hand needed to make from one number to the next in order to form the digits as the clock cycled through time. (Half a days work summed up in 26 words.. sigh..) Time to build some stuff!
Step 2: Order Materials
Disclaimer: I purchased most of the materials for this project locally over the course of multiple trips to the hardware and electronics store. These links serve as a way for me to share those materials with you and show what is needed to build this clock. I'd encourage you to shop around a bit to ensure you are getting the best deals.
3D Printer and Filiment
If you don't have a 3D printer, you'll need to get one for this project. You could have the parts printed via a printing service, but I wouldn't recommend that route as it is probably more economical to just buy your own printer due to the number of part you'd need to print. Plus if you buy your own, you'll have a printer that can what ever you want in the future! If you need to get one, I highly recommend the Ender 3 by Creality. This is the printer I used for this project and I actually just picked up a second one. They can be had for around $250 and print very well for the price.
- Ender 3 by Creality 3D - https://amzn.to/3g8LnrY
I chose to use black and off white PLA material for the individual clocks but you can be as creative as you'd like! For example, I ended up using some grey I had laying around when I ran out of material. If you're new to 3D printing, I'd recommend using PLA over ABS as it is much easier to print with.
- (2) HATCHBOX PLA 3D Printer Filament - BLACK - https://amzn.to/3yShkw2
- (1) HATCHBOX PLA 3D Printer Filament - WHITE - https://amzn.to/2W0qF6X
In total, this project needs 1416g of material or 470m. Assuming you want the clock bodies to be a different color that the hands, you'd need 1176g for the bodies and 96g for the hands. The rest of the components could be printed in either color and that requires 144g.
Electronics
- (48) SG90 9g Micro Servo - https://amzn.to/3CSRWc8
- (3) PCA9685 16 Channel PWM Servo Motor Driver - https://amzn.to/3skTBCb
- (1) DS1302 Real Time Clock Module - https://amzn.to/3m7XJ7E
- (1) Arduino Nano V3.0 Micro Controller - https://amzn.to/3AIoxiU
- (1) 5v 2a DC Power Supply - https://amzn.to/3yU9dPF
- Assorted Jumper Wires - https://amzn.to/3k0ifUT
Building Materials
I used the cheapest hardwood I could find at the lumber store (poplar) and went with a Mahogany all-in-one stain/poly from Varathane. Again, be as creative as you'd like! Maple? Cherry? The choice is yours!
- 3' x 16" x 3/4" Poplar board - Local lumber store
- Varathane Mahogany Satin Stain and Polyurethane - https://thd.co/2VL2Qx7
- 320 Fine Grit Sand Paper - https://amzn.to/3g6qjm3
- 100 Medium Grit Sand Paper - https://amzn.to/37LbG31
- Stain Applicator Brush (or equivalent) - https://amzn.to/3xPttAG
- (100) #4 3/8" Phillips Pan Head Sheetmetal Screw - https://amzn.to/2UiUz5q
- (96) M2.5 6mm Socket Head Cap Screws - https://amzn.to/3ANxhEC
- Super Glue Gel - https://amzn.to/3g5ZU7I
- (Optional) Multipurpose Lubricant - https://amzn.to/3xKUpRX
Tools
You should be set if you have the basic DIY tools (drill & drill bits, screwdrivers, tape measure, and a square). I did need a table saw to trim down the piece of hardwood I got from the lumber store, but they may be able to cut it for you at the store.
Also, I chose to use a 1/4" radius router bit to round off the edges of the board, but this step is optional. If you don't have a router or don't want to break it out for this project, just sand down the sharp edges a bit to prevent any splinters and make the clock easier to handle.
The one tool I did need to buy for this project was a 3-1/2" Hole Saw. I went with the Milwaukee Ice Hardened Hole Dozer! If you couldn't tell from the name, this tool makes near perfect holes, very quickly. If you go the same route, you'll also need the adapter bit that the saw attaches to.
- Milwaukee 3-1/2-Inch Ice Hardened Hole Saw - https://amzn.to/3yPV9a1
- Milwaukee Quick Change Hole Saw Mandrel, 1/4" https://amzn.to/3iKB0fL
Step 3: Print Parts
I've put this step first as it will likely take the longest. For me, the clock bodies took about 3 hours to print and there are 24 of them (72 hrs total not including down time). Did I say that second printer I bought was specifically for this project? Well it was.
In total, you will need to print the following parts. See pictures for orientation. The gears and rings are just printed lying flat.
Clock Assemblies
- (24) Clock Bodies
- (24) Minute Hands
- (24) Hour Hands
- (24) 12T Gear w/ Small Hole
- (24) 12T Gear w/ Big Hole
- (24) Retaining Rings
- (48) 32T Servo Gear
Misc.
- (2) Stand Brackets
- (1) Clock Body Drill Jig
I printed everything without support and without a brim and the parts came out good without any print failures. Also, I used a low resolution and very fast speed to finish the prints faster but I would not recommend this. If you can afford the time, print everything in medium to high resolution to get the best dimensional accuracy. At a minimum, print the hands and gears in high res. It is easy to drill out the center of the clock body using an appropriately sized bit, but it is much harder to consistently sand down the outside of the hand shafts.
Attachments
Step 4: Cut the Front Panel
While your parts are printing, you can shift focus to preparing the front panel all the assemblies mount to.
The panel should have a finished size of 16" x 36" x 3/4" thick. If your lumber shop wasn't able to cut the wood for you, break out the saw and cut the panel to size. I used a table saw, but a track saw, circular saw, or even a jig saw should get the job done.
Next, I finished the edges with the 1/4" radius router bit. You could wait to do this until the end, but I chose to do it now to make the board easier to handle. That said, rounding the edges first also makes it more difficult to take measurements from the edge of the board.. If I did it again, I would cut the holes for the clock first then finish the edges. I'd recommend you wait as well.
With the panel cut, we now need to drill the clock holes with the Hole Dozer!! Can you tell I like the name?
- Choose which side of the panel you want to be the front. Use this side to make your marks and drill from in the steps below.
- In the vertical direction, make pencil marks at 4", 8" and 12" on both the left and right sides of the board about an inch from the edge.
- Using a straight edge, make lines across the board at each vertical marking.
- Grab the tape measure and for each horizontal line, make a mark at the following measurements; 4", 8", 12", 16", 20", 24", 28", and 32". You should now have a grid with crosses at all the points at which you need to make a hole.
- Using a 3/16" drill bit or similar, drill a pilot hole at each cross. This will help give the hole saw a point of reference for staying on target when you initiate the saw.
- The time has come! Using the 3-1/2" hole saw, drill a large hole at each pilot hole. Your drill should be set to high speed and I've found it works best to apply pressure in a circular direction as your drilling to help the saw cut better. Also, this is best performed with a corded drill but a good cordless will work as well.
With all the holes cut, now you can finish the edges with the router should you desire.
Step 5: Finish the Front Panel
This step is comprised of two main steps. Sanding and staining.
Sanding
I sanded everything by hand but power tools would have likely been useful here as it did take a good amount of time to get the board smooth. Work smarter, not harder.
- There will likely be some splinters on the back side of the holes and a sharp edge on the front from the hole saw. Using a course grit sand paper (around 100), break the edge on the front and clean up the edge on the back
- If you didn't round off the edges, use the course grit sand paper to break the corner along the outer edge of the board.
- Using a fine grit sand paper (around 320), sand away the pencil line from the hole cutting grid.
- Using the same fine grit sand paper, sand down the entire panel till it's smooth. This step is purely aesthetic, but the more time you spend here, the nicer the panel will come out after you stain.
Staining
Depending on the stain you chose, these steps may need be modified. I went with an all-in-one stain/polyurethane to color and protect in one step, so these step will reflect the process for that. If you went with a traditional stain, I'd recommend finishing with a polyurethane or varnish of your choice to protect the wood. Or if you're happy with the finish of the wood and don't wish to stain it, feel free to skip this step.
- Lay down some protective cardboard or plastic to prevent the stain from dripping onto your table or floor.
- Setup the panel on blocks with the front side facing up and wipe off any wood dust using lightly moist microfiber cloth.
- Open and stir the stain/poly and grab the application brush.
- Apply a coat of the stain to the front and outer edges of the panel. You'll also want to liberally coat the inner surface of the clock holes. NOTE: The stain will drip though and likely wick a bit on the back surface through the holes, but don't worry about it at this step.
- After 30 min of drying time, flip the board and apply stain to the back side. During this step, do not re-coat the sides or the clock holes. This will keep the stain from wicking onto the front face. If any stain gets in the holes, simply wipe it with the brush before it drips down to the front face.
- Take a break and let the board dry over night.
- At this point, the front and back face will probably feel a little rough. This is caused by swelling of the wood fibers due to the water in the stain. Simply grab your fine grit sand paper and lightly sand the board again until it's smooth.
- Following the same steps as before, stain the front and back of the board and let it dry over night.
- Lastly, grab a razor blade to cut off any drips that formed on the back surface.
You should now have a nice looking panel to mount the clock assemblies too!
Step 6: Assemble the Clocks - Test Fit
Now that the panel is finished and you've fished binge watching that TV show, the 3D printed parts should be done meaning, it's time to assemble the clocks!
In the photos, I've included an exploded view of how the clocks go together.
Go ahead and test the fit of all the parts. If you printed in high resolution, everything should fit together ok. At most, you may need to break the edge on the clock body where the hour hand goes through. If you're like me and printed the parts in low res or things aren't fitting together, you'll need to sand, drill, and cut the parts a bit.
The steps below outline the process to test and modify the parts as needed.
- Test the fit of the 12T gear w/ small hole to the minute hand. It should be tight, but not impossible to get the gear on. (Sorry I don't have a picture of this)
- If the parts don't fit, progressively drill out the center of the gear until it fits on the hand. These parts will need to be glued so don't make it too tight.
- Test the fit of the 12T gear w/ large hole to the hour hand. The fit should also be tight.
- If the parts don't fit, progressively drill as needed.
- Test the fit of the retaining ring on to the hour hand. The ring should seat on the lip designed into the hour hand. The fit should be tight.
- If the parts don't fit, you're going to want to use fine grit sand paper (around 320) to sand the outside of the hour hand where the ring is supposed to slide over. NOTE: Try to isolate your sanding to only remove material from where the retaining ring sits.
- Take a look at the base of the shaft on the minute hand and inspect for any bulges or build up of material.
- Remove any extra material from the base or the shaft. The shaft should make a 90 degree angle with the base around the entire circumference.
- Test the fit of the shaft of minute hand to the inside of the hour hand. If the parts fit together, rotate the minute hand to test for friction. The fit should be friction free as the parts need to rotate within each other.
- If the parts don't fit or there is fiction as the minute rotates, you'll want to drill out the center of the hour hand. For me, this was accomplished with a #18 drill bit (0.1695" dia.). NOTE: Don't over drill the hour hand and this will translate to play in the assembled state. I'd recommend using a set of calipers to measure the diameter of the shaft on the hour hand and buying a drill bit that is around ".005 - .010" larger than that diameter.
- Test the fit of the hour hand to the inside of the clock body from both the front and back of the clock body. The fit should be friction free as the parts need to rotate within each other.
- If it fits from the back and not the front, there is likely a lip on the face of the body that was on the build plate of the printer. This can be removed by running a razor blade around the circumference of the shaft on the body.
- If doesn't fit from the back or the front, take a look at the outer shaft of the hour hand. If there are bumps or pimples from the 3D printer, you'll need to sand these down down then test the fit.
- If it still doesn't fit after sanding, you'll need to drill out the the center shaft on the clock body. For me, this was accomplished with a 21/64" dia. drill bit. Same as the hour hand, use a set of calipers to measure the shaft of the hour hand, and use a drill bit that it around around ".005 - .010" larger in diameter to drill the clock body.
If you need to perform any of these steps, you'll likely need to do the same for each set of parts so rinse and repeat this procedure until all 24 sets of parts fit together as they should.
Step 7: Assemble the Clocks - Glue and Screw
Hopefully you were able to skip the previous step but if not, my heart is with you.
With all the parts fitting together, it's time to glue and screw! i.e. assemble the clocks.
Assembly
- Insert the hour hand through the clock body and grab a retaining ring. Apply a small amount of super glue to the inner diameter (ID) of the retaining ring and slide it onto the hour hand from the back. Ensure the ring is fully seated so there is no translational play in the hour hand. NOTE: Be conservative with the glue. You don't want to accidentally hit the upper part of the shaft with glue when you install the ring, and you don't want the glue to over flow down the shaft and lock the hand in place on the body.
- Grab a 12T gear with the large hole and apply a bit of glue to the ID of the gear.
- Slide the gear onto the hour hand. Ensure it is fully seated so the gear on the servo will align properly.
- Grab a servo, route the cable the though the mount and seat it in place. NOTE: The servo needs to be installed with the shaft directly across from the center shaft (see picture)
- Screw the servo into place with the M2 screws and repeat for the other side.
- Grab two of the servo gears and one by one, slide them onto the servo shafts. NOTE: There aren't any teeth on the inside of these gears and they have a pressure fit. They are best installed by gradually applying pressure in a circular motion to the top of the gear.
- Use the screw that came with the servo to mount the gear into place. Repeat for the other side.
- Adjust the hour hand so it is near the 12 o'clock position by placing a little pressure on the servo gear to disengage it from the hand and rotating the hand as needed.
- Install the minute hand into the center of the hour hand and rotate it to be in the 12 o'clock position.
- Grab a 12T gear with the small hole and apply a bit of glue to the ID of the gear. Slide the gear onto the minute hand from the back of the clock. Ensure the gear is fully seated.
You should now have 1 assembled clock! Woo!
Now for the other 23.. NOTE: Patience will be required.
Step 8: Assemble Clock to Panel
You did it. All 24 clocks. Good job.
This step is one of the easiest. We just need to drill the mounting holes for the clock bodies and mount everything up. We'll be using the 3D printed jig to dill the holes and ensure the the clock bodies will line up.
Drilling the Mounting Holes
- Grab the wood panel again and set it up on some blocks with the back facing up. Cover the blocks with towels so you don't scratch the front face.
- Install a 1/16" bit into the drill and place the jig into the first hole.
- Using a square (or your eyeball) rotate the jig to be parallel with the edge of the panel.
- Place the tip of the bit into the hole on the jig and carefully drill the holes to a depth of 1/2". Go slowly as you do not want to drill through the front of the panel. An easy hack for this it to place a small O-Ring onto the bit 1/2" from the tip and drill until the O-ring touches the jig. The ring will walk overtime and you might need to re adjust but its better than doing it blind.
- Repeat for the remaining 23 holes.
- Position the two support brackets on the back of the panel about 1.5" from the outer edge and in-line with the bottom edge. Drill to the same 1/2" depth.
Installing the Clocks
- Grab a clock and place it face down onto the panel.
- Using 4 of the #4 sheet metal screws, mount the clock into place. I used a regular screwdriver for this to ensure I didn't over do it.
- Repeat for remaining 23 clocks.
- Using the same screws mount the two support brackets.
- Flip the clock and enjoy your work!
Take a good break here because you are about halfway done and you deserve it!
Step 9: Wiring It All Together
On to the electronics!
Before we get started we'll need to make a few modifications to the PWM servo drivers so we can daisy chain them all together.
PWM Drivers
- If your drivers didn't come assembled, you'll need to assemble them. If you bought unassembled ones, I'm going to assume you know how to do that.
- On two of the drivers, solder a header to side of the board that doesn't have one. This will allow them to be daisy chained together. Set one aside.
- Next, we need to bridge two contacts on the board we didn't set aside to give it a unique address. For this board, that will the "A0" contacts. Using a soldering iron and a bit or solder, drag the solder across to connect the pads. Ensure the other pads remain intact and not bridged.
- Lastly, on the board you didn't solder an additional header to, bridge the two contacts labeled as A1.
With the drivers ready to go, it's time to wire it all together. There are a lot of servo connections so it will get a bit hairy but I was able to make it fit without having to extend any of the servo lines. Take a look at the photos to see how I was able to make that work.
Wiring
- Route the servo lines through and around the clock bodies in a fashion that allows you to connect 16 lines to each board. If you'd like to copy my routing, take a look at the photo. If you don't copy my routing, you'll need to note which board and pin each servo is connected to. In the photos above, there is a matrix showing the naming convention I used in the code. Use this same convention so the code won't need to be modified later.
- Using the jumper wires, chain the three drivers together straight across. Double check your work to ensure the lines aren't crossed. The pins are labeled on both the left and right sides of the drivers and if you used different colored wires, it should be easy to tell.
- Using some more jumper wires, attach the Arduino Nano to the 1st servo driver per the attached image. I routed these into the lower right most clock body so I could hide the Arduino in there. Theres plenty of room, just double check to ensure the wires aren't hitting the gears.
- With a few more jumper wires, connect the Real Time Clock (RTC) to the Arduino per the attached image. I was able to hide this in the body directly above the clock with the Arduino.
- Lastly, attach the 5v power supply to the green screw terminals on the first PWM driver.
The clock should be looking pretty good now!! But unfortunately it's time for the hardest part.
Step 10: Calibrating the Positions
Ok full disclosure, this is where I learned I should have designed the clock assembly better to make this step easier.
The issue is, the gears aren't keyed to the hands so the 100 degree position of one is not the same as the other. As such, each hand needs to be individually calibrated to determine what degree command correlates to the 12, 3, 6, and 9 o'clock positions.
This is tedious but not impossible. I've wrote a bit of code to do it and made a chart to hold the results. The code allows you to send a position in degrees though the Serial Monitor to control the position of the servo you are calibrating. In short, once you figure out what position corresponds to 12, 3, etc., you note that in the chart and the formulas automatically generate the main code to run the clock. In the future, I might update the design to have keyed gears but for now, you'll need to follow the steps below.
Before you begin, this process is a lot easier if you label each clock with the pin and driver board for each hand. Grab some sticky notes (preferably in three colors) and a pen. Take 8 notes of each color and write the following pairs. "0-1", "2-3", "4-5"... etc. These will be the minute-hour pin pairs for each clock. Setup your clock and place these notes onto the front to the panel next to the corresponding clock body.
Calibrating the Positions
- Download and install the Arduino Coding program if you don't already have it.
- Download and open the excel workbook titled, "Clock Calibration and Code" at the following link, and navigate to the, "Calibration Table" sheet. https://www.dropbox.com/s/d0z3y5zufrs3mm8/Clockce...
- Download the Adafruit-PWM-Servo-Driver-Library at the link below and place it in your Arduino library folder. The library folder is usually in the documents\Arduino flower on you computer. https://github.com/adafruit/Adafruit-PWM-Servo-Dr...
- Download and open the Arduino sketch titled, "Calibrating_the_Positions" attached below.
- In the main void loop, modify the line of code for the lowest row first column clock hour hand (C1H per the naming convention) . Replace the "3" with the board your hour hand is connected to, and replace the "14" with the pin number that hand is connected to. "board3.setPWM(14, 0, pulse2);"
- Ensure your board is set to the Nano and the correct serial port is selected in the Arduino software. Open the Serial Monitor and upload the sketch. The serial monitor should read "Ready for Command".
- Send "120" to the servo. The hour hand should to its corresponding 120 position.
- Now, you're going to need to jump the gear mesh to get the arm facing somewhere near the 12 o'clock position while leaving the servo in position. This can be done by gently puling the servo gear away from the corresponding hour gear, and rotating the hand until its facing the 12 position. NOTE: It doesn't need to be perfect, just in the 12 o'clock vicinity.
- With that adjustment complete, send "80" to the servo. The hand should move in clockwise direction.
- Now you'll need to switch between a command around "120"and the "80" command, and keep modifying the 120 number until you find out what command corresponds to 12 o'clock. Once you get it, note this in the excel sheet for the C1 hour CCW column.
- Next, switch between your 12 value and something around "80" until you get the number for the 3' o'clock position from the clockwise direction. Note this in the table in the C1 hour CW column.
- Then, switch between your 3 value and something around "40" number for the 6 o'clock position from the clockwise direction. Note this value.
- The 7.5 o'clock position is calculated in the table so don't worry about this one.
- Switch between your 6 value and something around "10" to get he value for 9 o'clock in the CCW direction.
- Because the gears aren't perfect, you'll now need to repeat this in the counter clockwise direction as the values will likely be a little different and the each hand will need to hit the positions from both directions for the various numbers.
You now should have one hand calibrated on the first clock!!
Modify the numbers in the "board3.setPWM(14, 0, pulse2);" code for the C1 minute hand and repeat the process. Once complete, you'll need to repeat this for the remaining 23 assemblies.
In the chart, you'll notice some cells are greyed out. This is because those positions aren't needed to make the larger numbers for that specific hand.
I apologize in advance for how tedious this is but once complete, I can honestly say the hardest part is over.
Attachments
Step 11: Calibrating the Numbers
If you'll made it though to this point, this is where the clock will come alive!
I've already gone though the effort of determining where each hand needs to go to make each larger digit and better yet, the code will be automatically generated in the excel sheet!
You just need to take that code, upload it and make some fine adjustments for each number.
Calibrating the Numbers
- Open the, "Calibrating_the_Numbers" sketch attached below.
- Navigate to the, "Angles for Code" sheet in the excel workbook.
- IF AND ONLY IF you used a different servo pin connections than me, enter these now into the, "Servo Board and Pin Assignments" table.
- Otherwise, scroll down past the black line and copy the code for the first digit.
- Paste it into the Arduino sketch at the very bottom.
- In the code you just pasted, modify the bold number in this line to "11". "if (number == 0) {". This will be used to send a "0" to the clock.
- In the main loop, modify the bold number for the digit you are calibrating. "digit4(number);"
- Upload the sketch and open the Serial monitor. You should see, "Ready for Command".
- The numbers are meant to only work in sequential order. 1, 2, 3, etc. Go ahead and send a "11" to the board but don't freak out if it's off. It was assuming a "2" was there before. Cycle though the other numbers 1, 2, and 11. you should now see something close to a "0"
- Now is where you'll need to modify the angles as much as you wish to perfect the positions fo the hands. If you have the stickies still up this isn't at hard as it sounds. Say you're moving from a 0 to a 1 but don't like the position one of the hands is at. Note the board and pin of that hand and scroll though the code to the lines under, "else if (number == 1) {". Find the line where that hand moves, and add or subtract bit if you want the hand to move a little more in the CW or CCW direction respectively.
- If you don't see the line of code where that hand moves, its because it didn't need to move from its previous position to make that number and was set before hand. In this case, go backwards though the numbers, 0, or 2, find that line, and make your modifications there.
- Once satisfied, copy your modified code, and paste it a few columns over from the original in the excel sheet. IMPORTANT: You need to change the "11" in the line, "if (number == 11) {" BACK to a "0". If you don't, the later code won't work right.
- Repeat for the 2nd, 3rd, and 4th digits. For the 2nd and 4th digit, you'll be calibrating the numbers 0-9, and for the 3rd digit, 0-5.
Thats it! You now have the code that will make the numbers we need to show the time!
Attachments
Step 12: Setting the Time
Almost there! I promise.
The DS1302 Real Time Clock (RTC) module is cool because it has an independent battery and will store the time even if the Arduino Nano doesn't have power. But just like any other clock, the time needs to be set.
Setting the Time
- Download the, "DS1302" library at this link and place it in your Arduino library folder. https://github.com/msparks/arduino-ds1302
- Open the Arduino environment and open the example sketch, "set_clock" by navigating to File/Examples/arduino-ds1302-master/set_clock.
- This is the bit of code that will set the time but first, we need to attach two jumper wires from the 3.3v and end pin on the Arduino Nano, to the VCC and end pin on the RTC respectively. These lines are only used to set the time. if you leave them connected, the time will reset every time the Arduino sees power.
- Next, we need to modify the code to tell it where our clock is connected. This is done by modifying the bold numbers in, "const int kCePin = 5; // Chip Enable" "const int kIoPin = 6; // Input/Output" "const int kSclkPin = 7; // Serial Clock" from 5, 6, 7 TO 4, 3, 2.
- Scroll to the main loop and find the line, "Time t(2013, 9, 22, 1, 38, 50, Time::kSunday);" this is in the format of, "Time t(Year, Month, Day, Hour, Minute, Second, Time::kDayOfTheWeek);"
- We only need the time, but go ahead and modify everything to be correct and upload the code.
- Open the Serial Monitor to verify the code was successfully uploaded. You should see a print out in the format of, "Sunday, September 22, 2013 at 01:38:50."
- Disconnect the jumpers.
Step 13: Upload the Main Code
You did it! You made it! One more step and the prize is yours.
All that's left is to update the main code with the custom values from your calibration and enjoy your fine piece of art.
As mentioned previously, the numbers are meant to change in sequential order. If the wrong number is present before a change, it likely won't work right. As such, this code initializes by cycling each number from 0 to its max for that digit and then back up to the number of the current time. So say on the 2nd digit we need a "4", that digit will go from 0-1-2-3-4-5-6-7-8-9-0-1-2-3-4 to ensure a "4" is actually shown.
Other than that, the code is pretty simple. It checks the time every 15 seconds and compares it from the time 15 seconds in the past. If the time has changed, it sends the new time to the digits that need to move and moves those hands! I did my best in the code to comment things to describe what's happening.
Upload the Main Code
- Open the, "Clockception_Main_Code" sketch in the Arduino software.
- Copy your custom code from the excel sheet, and paste it into the sketch at the very end.
- Upload the sketch and sit back to watch your work come to life.
If I did a good enough job outlining this instructable, you should now be looking at the current time! Sit back for a minute or two to make sure the time changes.
Once you're ready, you can move the clock to its home!
Attachments
Step 14: Enjoy Your Clock!!
Well, Thats all Folks! You've successfully created a replica of the ClockClock for a fraction of the cost.
I hope you enjoyed this instructable! If so, I'd greatly appreciate your vote in the First Time Author contest.
If you have any questions or comments, please feel free to reach out! Im happy to answer any questions :)