loading

Hey all instructable goers! This is my first project. Yes, I know those words usually get the stereotype "This isn't going to be a good project" attitude, but I have been waiting a long time for a project that is worthy of possibly breaking the first project attitude- at least for a while anyway.

This project would be about medium level for a novice, but *hopefully* still provide somewhat of a challenge for more experienced users, as they get into the code and work on improving this.  "This" that I have mentioned multiple times, is an Arduino clock, based off of a 4 digit display. I have named this project the "TimeDuino". Its a simple 4 digit clock, driven with Arduino and transistors. Well, enough boring you with the introduction, lets get to the project!

Well, a few more things actually :)
1. In the spirit of instructibles and the growing DIY world, feel free to use this project, hack it, open it, tear the code apart, and in any way you want destroy/hack/DIY it to your hearts content. I want everyone to be able to access the project, and not have to worry about proper permissions. I really like the quote from MAKE: Magazine, which states "If you cant open it, you dont own it". So OWN this project! Open it, hack it, tear it apart and make it your own. Go beyond the step by step instructions and really customize it! I really enjoy electronics, and i want to share that enjoyment with others.

2. Feedback is appreciated. Tell what you do or do not like! What needs upgraded and what needs reverted to a previous version? These things (though I might not be able to complete all of them) really help and make it easier to create something that is liked by the community. Have a question? Ask it in the comments, or PM me. I'd be happy  to help as much as I can.

Many thanks, and on to the project! :)
-Astroboy907

Step 1: Parts Needed:



1x Arduino. I used an UNO (but any version should work). Make sure it has a 16MHZ timer chip on it, otherwise timer functions will be off (until I update with an RTC [Real Time Clock].  To tell if it has the timer, it should have a silver oblong piece on the PCB, with 16.000 printed on it.

1x Power supply for Arduino (not shown)

1x Breadboard. A half size board will work, but a full sized one is easier to work with (I'm using 2 half size boards together. 

Breadboard Jumpers - quite a few are needed.

7x 2N3904 NPN type transistors (maybe 8 for AM/PM support, working on that)

8x resistors. Try for a value greater than 200 ohms and less than 1k. I'm using 220 ohms. (10x if I get AM/PM support)

7x 1k ohm resistors. These will keep your Arduino from overheating (8x if i get AM/PM)

1x 4 digit 7 segment display. I used a common anode display (but a common cathode would work with editing the code). Make sure it has a colon! One used in project-  Sparkfun COM-09481
also available in red, green, and yellow (blue costs 50c more than the other colors. I got 2 just in case [but these are almost unbreakable if you remember to use resistors])

*Note that if you want to just build it w/out testing, you don't need the breadboard and jumpers. I wanted to test mine first but I'm gonna build a finished up prototype when I get some other parts.

Step 2: Laying Out the Transistors

Possibly the most crucial element of this project is laying out the transistors correctly. The transistors allow a connection to ground to be made using positive voltage. Start spreading the legs of the transistors a little bit, making sure they fit into their respective holes (as shown in pics). Make sure there is at l east one empty row between the transistors. Double check to make sure the FLAT side is facing you, otherwise it will not work. Do this for all 7 transistors. Lay out an extra one if you will be doing AM/PM support

Step 3: Start Wiring Up All of the Transistors

Ah, the first real wiring job of this project. Use jumpers to connect the collectors of the transistors (in picture below) to the ground rail on your breadboard. Connect a jumper from the ground rail on your breadboard to a ground pin on the Arduino board. As you can probably see, paint is not my strong suit :)

***WARNING!! The following section may contain science relating to electrical components and how to use them. Continue at your own risk. Thank you.***

Basic transistor lesson. To use an NPN transistor, placing current on the base pin lets proportional current through the collector pin to the emitter pin. Very basic, as transistors have different minimum currents, maximum ratings, and different current capabilities, along with much else. Luckily, a 2N3904 is very kind to us, and perfect for small scale, high frequency switching with a low power source, such as an Arduino. Yay!

Step 4: Add Resistors to Your Transistors. Say That 5 Times Fast!


Now you must add resistors to the emitter of the transistors, else you might accidentally fry your display when you hook it up. We wouldn't want that, would we?
Connecting is simple, go from the emitter, jump over the center of the board, and connect it to the other side.
Depending on your resistors, the display might be dimmer when you hook it up, the higher value your resistors are.



Step 5: Even More Resistors

By adding these resistors, it will keep the Arduino from using to much current and then overheating. You need to connect a 1k resistor from the base (middle pin) of each transistor to the empty row to the left of your transistors.

Step 6: Now for the Harder Part (connecting the Display)


Connecting the transistor output to the display is harder. Make sure you have your display's datasheet ready, because you'll need to look at the pinouts there. For my display, I connected the transistors in order from segments A to G, using the farthest left transistor for A, and the farthest right as G (and an extra one for my AM/PM, ill call that one segment H from now on). It helps keep things a little more organized. Which transistor goes to which pin depends on your display and its pinout.

Step 7: Connect the Display to Arduino


For our first test, you will need to connect the Arduino output pins to the specific transistors.


For segment A: connect pin 12 (on Arduino) to the first (leftmost) 1k resistor (connected to transistor base [middle pin])
For segment B: connect pin 11 (on Arduino) to the second leftmost 1k
For segment C: connect pin 10 (on Arduino) to the third 1k
For segment D: connect pin 9 (on Arduino) to the fourth 1k
For segment E: connect pin 8 (on Arduino) to the fifth 1k
For segment F: connect pin 7 (on Arduino) to the sixth 1k
For segment G: connect pin 6 (on Arduino) to the seventh (rightmost) 1k
For segment H: connect pin A3 (on Arduino) to the 1k on your H segment transistor. This is not actually used in the test.

Step 8: Almost There!


Connect the digit power pins (1, 2, 6, 8 on my display respectively) to pins 5, 4, 3, and 2 on the  Arduino. Goes as follows:

Digit 1: pin 5 on Arduino
Digit 2: pin 4 on Arduino
Digit 3: pin 3 on Arduino
Digit 4: pin 2 on Arduino
Colon: pin 3 on Arduino (not used in test)
PM dot  (apostrophe) connected to pin 2 on Arduino, and its respective ground pin to ground)

Step 9: Test the Display!


The time has finally come! Time to test your display and it's transistory goodness!
Download and run the code posted below. Note that if it downloads an a .tmp file, it's ok, just rename it as a .pde file and run it in Arduino on your computer.

You should see a variety of patterns and tests go on the digits. If anything seems out of place, check your wiring. Here's a video showing you what an ideal test should look like. UPDATE: I got video embed to work :) My thanks to user Burf for guiding me to the right page.
 

If all goes well, skip the next step and continue on. If it doesn't seem to work, go to the next step.

Step 10: Troubleshooting :(


Troubleshooting. Even a mere mention of the word can strike fear into the hearts of people everywhere.  If your display doesn't work, there are a few things to check.
Make sure your transistors are oriented correctly, the flat side should face you. Make sure the resistors are connected to the leftmost pins of the transistors, and that the jumpers from the resistors to the display are hooked to the corresponding pins. Lastly, make sure  you connected the displays jumpers to the correct Arduino pins. I once had a dim, flickering segment, it turned out only to be a loose resistor. If nothing works and everything is connected right, check your display, maybe some segments are burned out. Hope this helps!

Step 11: Finally! the Clock Part!

Well if all the test went ok, it's time to make your clock a clock. We have to re-arrange the pins from the display and the pins on the Arduino (so I can have some extra pins for possible PWM control later)

*Note. Its best to blank your Arduino, it makes it easier to upload the next sketch (sometimes it freezes). To do this, go to File>Examples>Basics>BareMinimum (or equivalent) and upload it to your Arduino.


So here goes.
Seg A to pin 12 on Arduino
Seg B to pin 8 on Arduino
Seg C to pin 7 on Arduino
Seg D to pin  5 on Arduino
Seg E to pin 4 on Arduino
Seg F to pin A0 on Arduino
Seg G to pin A1 on Arduino
Seg H where it is

Digit power pins:
Digit 1 to pin 11 on Arduino
Digit 2 to pin 10 on Arduino
Digit 3 to pin 9 on Arduino
Digit 4 to pin 6 on Arduino
Colon where it is. Make sure to connect your colon ground pin to ground! Mine had a different pin than the rest of the digits outputs.

Step 12: Upload the Clock Code

Update: Version 1.4! This update includes AM/PM support, as well as a much simpler code.

To use the code, download the file included below. It should download as a .tmp file, just rename it as a .zip file. Unzip the file into your arduino sketch folder. In arduino, go to Sketchbook>TimeDuino_v1.4 and open it. It should have a program with 3 tabs in it. Go to the third tab to set your variables. Make sure to read the comments!

When uploaded, it should display 9:42, with the PM dot on.

Step 13: Possible Updates/improvements


I have some updates for this clock that should be posted if I can get them to work...

v1.1 - AM/PM time using a decimal and apostrophe on display

v1.2 - Adding buttons to set time

v1.3 - Blinky colon support, will blink the colon every second (like some clocks)
UPDATE! Blinky colon support (read through code to see how)

v1.4 - 24 hour clock configuration
UPDATE! 24 hour clock supported. Read code for details

v1.6 - Possible seconds addition, using another 2 digits, making it a 6 digit display

v1.8 - RTC support (I have a DS1307 clock chip on order, as well as the needed extra components to get it to work, but it will take me a while to get it and make it work) This will (hopefully) eliminate the timing problems (the display goes a bit fast, testing to try to lessen the effect)

another few updates would maybe include common cathode display support, thus eliminating the need for a specific display, and adding an alarm and snooze.

Step 14: Thanks To: (and Final Note)

I just wanted to thank the people here for posting the code which I based my clock on. Also to instructables for letting everybody post their projects here :)
Thanks to user Burf for helping me get to the right page to figure out my video embed problem.
Also many thanks to users maewert, stevastrouk, and rickharris for helping so much with the overheat problem!

*Final note:
If you wish to use your Arduino for another project, it helps to remove all the wires from it, and then upload your desired sketch. If you don't remove all the wires, it sometimes freezes up and won't let you load anything.
I noticed there's a bug, where after the clock cycles a few times, the hour1 digit does not turn off when it's suppose to... Any ideas on a fix?
about how many cycles? I'll try to take a look through the code. Also- sorry I havnt been keeping up with this. My schedule is shot to heck with school....
I keep getting use of undeclared identifier
I found a fix!<br><br>The issue seems to be with counter2<br><br>It sets counter2 = 1, but it never resets it back to 0.. <br><br>I added the code to reset it here:<br><br> if(hour2counter == 25){<br> hour2counter = 1;<br> hour2 = 1;<br> hour1= 0;<br> counter2 = 0;<br> }
<p>Thank you!</p>
ok. Test and see if that works! I think it should :)
<p>full circuit pls</p>
<p>I used only 4 resistor and remove all transistor by reversing the logic of pin d9-d12 HV to LV and vice versa. </p>
Mantab Jiwa..
So beautiful! Thanks for the wonderful 'ible!!
<p>Would you please send me the whole program code @ sharmaattarun125@gmail.com. I am also working on arduino MEGA and would really appreciate the help.</p>
<p>How can i set this with the use of buttons to adjust the time???</p>
<p>How hard would it be to add an Ethernet shield and get the time from an internet NTP server ? So query the server every hour and update accordingly ?</p>
<p>Thanks so much for this Instructable! I just got into Arduino, and and looking for projects and wanted to make a clock, but still need some guidance before taking it on solo. Exactly what I needed and very well done!</p>
<p>can u please send me circuit digram at toobakhan782@gmail.com</p>
<p>could you please send the circuit digram??</p>
<p>I've only got 1 transistor :( where do i get more from..</p>
<p>You can easily buy them from any electronic component store. Here is a good site https://www.sparkfun.com/products/9481</p>
<p>Could you please send the wiring diagram ?</p>
<p>sir,can i use bc547 without using 2n3904</p>
<p>Thanks. I have used Cheap Aliexpress Common Anode Version and by simply making a #define ON i was able to switch it from Common Cathode to Common Anode.</p><p>I found several datasheets online but this one makes it perfect.</p><p>Read xtracode.ino bottom for your pins attachment.</p><p>Can someone tell me how to change the code for ( blinking the two leds between number also blinks bottom 3rd led.)</p>
<p>Easyly Add Resistors For It.</p>
<p>Hey there,</p><p>Any updates on making the newest code available? The only version I've found was 1.4, but there is *supposedly* a version 1.8 listed here, which *claims* that it has a lot of neat features, like RTC support. So, whaddya say? Could you post a link to that code please?</p><p>...or did I just have too many dumburgers for lunch today, and am overlooking the link to version 1.8?</p>
<p>What can I do if I have a common cathode display?</p>
<p>junk it and buy a common anode display instead. Way easier.</p>
<p>It was my Halloween costume! Plus I finally got a primer in my Arduino. I even had most of the parts - just needed the LED display, the transistors and resistors. Thanks for posting!</p>
<p>Great project, thank you! I'd like to add seconds and buttons, still learning the code. </p>
<p>please can i have youre code? i need it badly for my project :( </p>
<p>Anyone wanna help me out here please :( My clock doesn't light up one of the segments on the first display ... As can be seen in the video :l</p><p>https://www.youtube.com/watch?v=ALfW0Y3GEqo</p>
<p>I was reviewing your instructable here to see how to modify it for my use (different display) and I found an error which could destroy the reader's Arduino. You are powering the LEDs from the Arduino pins, directly through the common wires. You are supplying too much current through the Arduino Pins and could possibly blow your Arduino Pins. Suggested modification is to use transistors on your digit power pins as well.</p>
<p>I replied to this and then noticed the last time someone responded. :)</p><p>I found out how to add the seconds and make them count up. I used the min1 and min2 for that. only renamed it a bit. I cleaned up the code a bit, as in, i removed everything that had something to do with am/pm because we don't use that here. All the digits are on the Analog port. the rest is on 7 to 13.</p><p>What is the interval for? what does it do? because i set it to 1000 and it run &quot;ok&quot;. 10 minut difference in 24 hours... but i'll find something for that.</p><p>Some pictures are included this time. All digits are 22cm by 12cm.(8.6&quot; by 4.7&quot;)</p>
<p>can i have your code?</p><p>i also live in a 24 hour area</p>
<p>The interval changes the time between the digit changes. So technically 1000 is supposed to equal one second of time, but due to the drift of the internal timers of the Arduino this can vary based on a number of factors (temperature, etc). In my tests I just toyed around with the interval until it started giving me reasonable times. However, interval isn't exactly a great way about going about the whole problem because the timer can drift erratically. The cheapest solution would probably be to rig up a DS1307 RTC chip to it and have it manage the time. You could even do that and probably get away with using the square wave output of the chip and not change the code much. That thing is a beast!! </p>
<p>If you wanted to do that it might just give me incentive enough to wire this whole thing up again and try interfacing a 1307 timer and figuring out the code...</p>
<p>I'm still playing around with it. It made a smaller version on a breadboard so i can easy test it.</p><p>I have a DS3231 RTC module, now i have to try to make the 2 things work together :) I'm learning as i go...</p>
<p>when will the ds1307 version be releced</p>
<p>I'm building this right now! :) so much fun...</p><p>But is there a easy way to add seconds? I've made a 6 digit one. I'll post some pics when there is more daylight.</p>
<p>Jeez... I forgot about this project for a while there! I can't believe it's hit 80,000+ views. That's just insane, especially looking at the code (it's not very efficient, and probably not very well written).</p><p>Looking at the code the way it is (sigh...) it would be possible to add seconds (as long as you have another 7 or 8 outputs on your arduino which you *should* have a few left). If you had your heart set on using the code as it is, I'd suggest doing something like duplicating the code relating to the min1 and min2 variables, but rewrite it with seconds variables. Then change the interval to ~6,000, and have it increase the seconds variables rather than the minutes. Add a couple counters to change the minutes when the seconds increases past 59 and you *should* be good to go. Oh yeah, and add outputs for the seconds LED segments. </p>
<p>Can you please send block diagram to nandhu.srly@gmail.com</p>
can you give me to this clock diagram
Very nice clock. One rather simple update to make it more accurate would be to use the millis function which return the number of milliseconds that has passed since the Arduino began running. Millis%60000 would then give you the elapsed seconds, millis%(60*60000) would give you the elapsed minutes and millis%(12*60*60000) would give you the elapsed hours. Then you can add these elapsed times with the clock time when the arduino was turned on (this is determined when the user 'sets' the clock at power up). The only other problem is the millis clock rolls over to zero after it hits it maximum value (after about 50 days) and you could detect this and correct for it. Using this approach you wouldn't need to update counters, etc. <br> <br>Just a thought. <br> <br>Best Wishes.
Hey- Thx for your comment :)<br>To be honest I completely forgot about the millis function :)<br>I'll start working on a version with that in it, see if I can get it to work the way you described. Also will be working on blinky colon and 24 hour time, so the next version might have all three in it. <br>
Ok I got the code running with millis() (it was a lot easier than I thought, I pretty much only copy pasted the example from Arduino and changed it around a bit)- working on the 50 day reset counter problem and I'm gonna let it run for a couple hours just in case :) Then I'll upload the code (I'll mention you in my 'ible too :) )<br>Thanks for mentioning it, it's so much easier than what I had before!
Hi Astroboy907,nice work. can you publish the newer code with the millis, also did you ever added the RTC into the clock? <br> <br>tnx <br>Amos
No real need to mention me since you're doing all the work :-) but I do appreciate the thought!<br><br>Best Wishes,<br>Mark
what do i have to modify to work with common cathode display <br>
very thanks for this great project . <br>but just I have question <br>Is it work with parallel Linux or processing ?? <br>if it's not can I make this clock with parallel Linux ? <br> <br>Best regards: <br>Lolo
If the arduino IDE is available for linux distribution (which I think it is at arduino.cc), than yes, it is.
Enjoyed the build. Thanks much for the project. Good luck with school.

About This Instructable

203,920views

110favorites

License:

More by astroboy907:Make a giant LED sign! (24x8 Matrix) Flickering LED star! Jailbreak iOS5! 
Add instructable to: