Clock project

Hi,
I have a few questions about a clock project involving an Arduino-Uno-bootloader-flashed ATMega328.
I plan to have it connected to a 4-digit 7-segment display that accepts input serially, and have the system battery powered and adjustable by buttons.

So, here are my questions:

  1. Is it possible to simply do this without a real time clock, using delay(1000) for each second? if so, should I store the current time on the EEPROM or simply as a variable?
  2. Should I use NewSoftSerial to communicate with the 7-segment display?
  3. How should I read input from the buttons?

Thanks in advance!

Is it possible to simply do this without a real time clock, using delay(1000) for each second?

Yes it is, but I wouldn't recommend it.
Think about it:

delay (1000);
updateClock ();

This will drift over time, as "updateClock" effectively increases the delay time, because it takes a finite amount of time to execute.
Also, you won't be able to see any button presses that occur during "delay".
Have a look at the "blink without delay" example to see a better way.

  1. Is it possible to simply do this without a real time clock
    If you look at the Time library, you'll see it works without a RTC. You'll still have issues with drift, however, if you later on you decide to add an RTC the code change is minimal. I'm not sure why you would write anything to EEPROM unless you wanted to know what time power was lost?

  2. Should I use NewSoftSerial to communicate with the 7-segment display?
    This will probably work okay since you never really need to read anything back from the display.

  3. How should I read input from the buttons?
    Just like you would any other buttons?

I strongly recommend a real time clock. They are cheap and easy to hook up. Plus, they can maintain time with a coin battery so you don't have to input time every time you restart your atmega.

The only chips under the "time" category in the shop I buy from are the NE555 and the NE556, would I be able to use any of these?

The only chips under the "time" category in the shop I buy from are the NE555 and the NE556, would I be able to use any of these?

The 555 is a timer (as in counter), not a real-time-clock. I'd look at a different shop. There is no shortage of them on the web. The DS1307 is a popular RTC and is supported by the Time library (which I still recommend using.)

You want something like this one from Adafruit called ChronoDot.

DS1307, couple of caps and I2C pullup resistors, all available for under $1 from dipmicro.com
DS1307 64 x 8 Serial Real-Time Clock DIP8 - dipmicro electronics
and wire up a little board

I am based in Israel, so finding these parts is a bit tricky.
I think I managed to locate a shop that sells the chip (DS1307), though.

Anyway - would a CR2032 battery work for this?
I found this: http://em.typodemon.com/wordpress/?p=149 - I assume it is accurate, is that right?
If so, I'm also going to buy two 4.7 Kohm resistors as pullups and a 32.768kHz crystal - is that okay too?

I spent the daybuilding a clock, then broke it by putting 10V the wrong way over it :0 . It was based upon the DS1307, an RTC. I have used it before without a problem, and would strongly reconmend that over delay(1000). I read somewhere that using delay can leave your clock up to 30 seconds out each day, making it completely useless for longer periods of time. (Up to 182 minutes and 30 seconds out over the course of a year). RTCs keep the time accurately for as long as they have power. The DS1307 module I have also comes with an onboard battery to keep time even when the main device is powered down. A very useful attribute. Check out eBay, they have plenty of modules.

Onions.

I think it's better to seek out local chips and parts.
So, then - my questions still stand -

  1. Would a CR2032 battery work for this?
  2. I found this: http://em.typodemon.com/wordpress/?p=149 - I assume it is accurate, is that right?
    If so, I'm also going to buy two 4.7 Kohm resistors as pullups and a 32.768kHz crystal - is that okay too?
  1. Yes. That will last a long time too.
  2. Pullups & crystal, that is correct.
    Can't open the link from here.
    If you are going to use the square wave output, you will need a pullup for that as well.
    100nF (0.1uF) cap across Vbat and Vcc would not hurt either.

I don't plan to use the square wave output.
Also, if I use a battery, do I wire it to the Vbat and ground (and ground to the Arduino's ground) while not wiring Vcc to anything? That's what I seem to understand from the spec sheet.

Pauly:
You want something like this one from Adafruit called ChronoDot.
ChronoDot - Ultra-precise Real Time Clock [v3] : ID 255 : $17.50 : Adafruit Industries, Unique & fun DIY electronics and kits

There much cheaper alternatives out there:
For pre-built modules:
http://emartee.com/product/42013/Arduino%20Tiny%20RTC%20DS1307%20Shield

And for 1307 clock chips/crystal/battery holder for DIY:
http://www.taydaelectronics.com/servlet/the-(-IC-)-Integrated-Circuits-cln-Real-Time-Clock/Categories
http://www.taydaelectronics.com/servlet/the-2009/32.768-kHz-Crystal-Cylender/Detail

--- bill

You will need a coin battery holder:

http://dipmicro.com/store/BH2025

And then I wire the positive lead to Vbat and the negative one to Ground & the ATMega's ground?

"Also, if I use a battery, do I wire it to the Vbat and ground (and ground to the Arduino's ground) while not wiring Vcc to anything? That's what I seem to understand from the spec sheet. "
Yes. Battery+ to Vbat, Battery - to DS1307 Gnd/Arduino GND.
VCC gets connected to Arduino VCC.

liudr:
You will need a coin battery holder:

If there is no need to replace the battery, you can use the batteries
with the leads attached to them (see futurlec "batteries" link above for an example).

--- bill