I am making a binary clock, and I dont know which one to do. Which one is easier to code?
24 hours per day (5 bits) , 60 minutes per hour (6 bits), 60 seconds per minute (6 bits).
Total 17 bits.
Just use I/O pins.
??? It's going to have 21 leds. I am doing:
AM / PM Lights (2)
Hour Lights (5)
Minute Lights (7)
Second Lights (7)
Total (21)
60 seconds (or minutes) requires only 6 bits. 26 = 64
It's going to have 18 leds.
AM / PM Lights 2
Hour Lights 4
Minute Lights 6
Second Lights 6
Total 18
Or be un-American and use the 24-hour clock and save a pin/LED. ;D
I don't understand... It takes 7 leds to show 59 seconds. The ones has to go to 9. The tens has to go 5.
I don't understand... It takes 7 leds to show 59 seconds. The ones has to go to 9. The tens has to go 5.
There are 10 types of people in the world - those who understand binary, and those who don't.
You're talking about BCD (binary-coded decimal), not binary.
Well, I ment a binary time clock, sorry. I am a total noob who JUST turned 12... I dont know it all yet...
That said, what control method should I use?
No, you meant a binary-coded decimal clock.
You really don't need any external hardware.
Assume you have 4 bit "digits" for HH:MM, so four digits.
You have four pins for the "digits", and four pins to select which "digit" you want to display at any particular moment.
Eight pins.
Plus two for your AM/PM indicator.
Oops, missed seconds.
Make that 10 pins. (plus 2 for the AM/PM)
So you're saying multiplexing (sort of)? Like row column? i think you mean 4 rows, and 6 columns? Am I correct?
When I made mine, I had two for the colon, five for the hours, and 6 for the minutes. It was in 24 hour time. No BCD here! I was going for pure efficiency with my I/O pins, as I also had hours set and minutes set buttons. The two for the colon were in series, so I ended up at exactly 14 I/O pins. Perfect for the Diecimila. I suppose I could have had an AM/PM indicator and moved the switches to the analog input.
Anyways, save some hardware by not using BCD. Be cost effective. That's a good trait in the long run.
If you ever decide to build a Nixie tube clock down the road, that's when you ought to look into multiplexing/shift registers. If you want to adjust the brightness easily, use shift registers with PWM on the B+.
Kyle
I am already settled on 21 leds. I am not changing that. I am building a standard BCD clock. I need to know wheather it is easier to code multiplexing or shift registers.
Adding a shift register is very very easy and you just need to use the shifOut command to use it.
So you recommend I use shift registers?
Unless you use latches, multiplexing results in a dimmer display. I don't know if that's a problem for you or not.
Have you considered a Mega? At least you would be able to save some hardware by getting one of those. It'd also save you some code while you're at it.
Kyle
use shift registers, like a 74hc595, they latch, and you can chain them, + you just use shift out
(lol I misspelled shift, and the censor put in "nuts")
The multiplexed version will be both easier to code, and easier to build.
Multiplexing your leds simply requires you to set pins high and low to select the digit and the leds in it you want to light.
Doing the same thing with shift registers would require three additional ICs and bypass capacitors to control your 21 leds. And depending on what type of shift register you use you may not end up with leds that are any brighter than what you'll get with multiplexing.
To multiplex the display, wire all the leds for each digit up so all the cathodes are connected, and then connect that common cathode to a pin on the Arduino. If you have six digits, that's six pins.
Once you have that done, you need to wire the anodes up. For each digit, you're gonna have leds 0..3 represeting the different bits. Take all the anodes for led 0 in each digit and wire those together. Then connect them to a pin on the Arduino via a resistor that is sized to power a single led of the type in your display. Do the same for the other 3 leds. This will take 4 pins. (Google led wizard to find the resistor size you need. Input the higher of the two forward voltages in the led data sheet, 5v source, and 20mA or less.)
Then in your code:
- Loop through your digits one by one.
- Set all anode pins low. (So when you select the next digit, none of the leds are already on before you select the ones you really want.)
- Set all cathode pins high except for the one for the digit you want to light.
- Set the anode pins high for the leds in that digit which you want to light.
- Pause for some period of time. Since you want to update your display at 60hz, you don't want to spend more than 1000ms / 60hz / 6digits = 2.7 milliseconds or 2700 microseconds, on each digit. So delay(2) will be fine.
And that's it. Except for your am/pm led. You can just wire that up to another pin with the same size resistor as the others going to ground.
Total: 10 pins to display 6 binary numbers, plus one pin to turn on on the am-pm indiciator. 11 pins in total.
(And if you want to get clever, you could wire the am/pm led up so that it behaves as one of the bits in one of your digits which doesn't require all four bits, like the tens portion of the hour display, which will save you a pin.)
Well, I ment a binary time clock
No, you meant a binary-coded decimal clock.
You're both right. Either type can be referred to as a binary clock.
Btw I would never have dreamed of building anything like this when I was 12!
When I was 12, after burning out all the ics in my electronics kit because I didn't understand anything about how electricity flowed in a circuit, I wired up the two transformers in such a way that they melted and then my mom took away the kit. ;D
I think I will use the 74hc595 chip. They sound easier to work with, and more pin effitient.
As for the mega: I don't want to put an arduino mega in it, because they are $65, and this is perminent... A few 35 cent chips is better than a 65 dollar arduino mega.
And yeah, I hope I dont blow up the house... My mama would take my arduino away.
They sound easier to work with, and more pin effitient.
If you want pin efficiency, use charlieplexing.
Six pins gets you thirty LEDs.
There's even a library in the playground.
21 will require three shift registers, they are easy to use, if you want to drive higher current LEDs then use the HEF4794 or a transistor on the output of the 595
This is what I did, I've not done more since.
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1205021534
You will probably want a stable time source since the Arduino does not have one.
http://www.arduino.cc/playground/Main/InterfacingWithHardware#Input