TimeDuino- 7 Segment Arduino Clock (No Shift Registers Needed!)

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

Supplies:

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.

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.

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.

Attachments

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!

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.

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!