Pages: [1] 2   Go Down
Author Topic: My first Arduino project - A clock  (Read 2644 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey guys I decided to start my first Arduino project! I also just joined this forum today so I'm a newbie here. I was hoping if you guys can provide some guidance along the way for my project, I'm planning to make a clock. The clock I'm making is very important to me, not only because it's my first project but I also want to give them as gifts to two friends of mine for their birthdays. I'm hoping to learn from this intelligent community of people and hopefully one day contribute to ideas of others. So without further ado here's what I'm using and what features I want for my clock:

Project : Clock
Microcontroller (mc): ATmega328 - Arduino Uno platform

*EDIT* After taking suggestions from you guys I came up with a parts list, most of which I already have. I would just like some advice on coding and a good way to put it together.

Parts:

1.  DS321 Module - http://dx.com/p/high-accuracy-ds3231-module-w-temperature-battery-blue-168974
 - Basically an RTC with a temperature sensor, just need help on coding and how to retrieve both time and temperature reading.

2. Standard 16 x 2 LCD screen - http://www.engineersgarage.com/electronic-components/16x2-lcd-module-datasheet
- I think I'm just going to read up on the library on how to use this but would love to hear any suggestions or ideas.

3. Infrared Sensor - http://www.creatroninc.com/index.php/sensors/distance-sensors.html
- Use this to shut off an alarm with the wave of a hand, any useful hints on coding would be greatly appreciated.

4. Buzzer - Self explanatory

5 . Buttons - Haven't bought enough, but I want a smart way to change the alarm settings, change pre -programmed text to show on LCD, another way to  to shut off an alarm and go into various mode settings. Any help in this aspect is greatly appreciated.

As for the power supply, should I use  a wall mounted one or a standard 9V battery? Would everything reset if I change the battery, I understand the RTC chip itself has it's own battery but not sure about the rest. Thank you guys!
« Last Edit: July 24, 2013, 02:51:06 am by DanT29 » Logged

London
Offline Offline
Edison Member
*
Karma: 46
Posts: 1368
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You haven't told us on what you intend to display the current time. Analog clock face, LCD, LED array or VGA monitor?
Quote
Has an alarm function - I have a buzzer, I'm guessing the rest is done with programming. I'm guessing interrupts.
No need for interupts
if (current time >= alarmSetTime)
while(alarmReset not pressed)
sound the alarm.
Logged

Canada
Offline Offline
God Member
*****
Karma: 7
Posts: 597
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Welcome to the community Dan.

It's all doable.  I'd use and RTC module as the Arduino by itself might not be accurate enough to bother broadcasting it's time around the world.  I do not see the need for interrupts in this application.  Memory might be a tad tight to run an RTC library, an Ethernet library and a WiFi library, but it should all fit if care is taken.
Logged

Facts just don't care if you ignore them.

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you for the alarm idea, I will certainly use that. I think my biggest challenge is going to be WiFi, would I still need an Ethernet library if I'm going to go wireless on this project?
Logged

Canada
Offline Offline
God Member
*****
Karma: 7
Posts: 597
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Not too sure.  While I've done lot's of projects that use Ethernet, I've not added WiFi.   Perhaps the WiFi libraries also contain teh IP stack.  We'll need to wait for people with actual WiFi experience to chime in.
Logged

Facts just don't care if you ignore them.

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'll be waiting for them! I'll try doing some research aswell. Thanks!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Since I'm on a tight budget I am making two of these clocks, I think number 4 (WiFi) is too costly to implement. But would love to learn how for future projects.
Logged

West Yorkshire, UK
Offline Offline
Edison Member
*
Karma: 40
Posts: 1204
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Dan,

I can reccomend one of these:http://www.google.co.uk/url?sa=t&rct=j&q=deal%20extreme%20ds3231&source=web&cd=1&cad=rja&ved=0CEEQFjAA&url=http%3A%2F%2Fdx.com%2Fp%2Fhigh-accuracy-ds3231-module-w-temperature-battery-blue-168974&ei=hHzRUbGnKIvY9ASRy4CoAw&usg=AFQjCNGndZSbBZC0bCv21TxNLZHF4QW4iA&bvm=bv.48572450,d.eWU

I've used one on a clock project and they are highly accurate and also have a built-in temperature sensor and alarm functions. It connects to the Arduino via an "I2C" interface. The library for this called WIRE I believe.

For power, the simplest option could be 3xAA or maybe 4xAA cells. If using 4, only rechargeables should be used. 4 non-rechargeable cells might be more volts than the Arduino will be happy with. Alternatively, a "wall-wart" type adaptor could be used if you build a voltage regulator circuit into your board. A 78L05 regulator should provide enough current for what you are describing (except for the WiFi stuff, which is too complex for a first project anyway). You will need some 10uf and 100nf capacitors to help with smoothing the supply also.

What kind of display were you thinking of? LED, LCD...

Paul
« Last Edit: July 01, 2013, 08:08:33 am by PaulRB » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey PaulRB,

Thank you for your reply, I just noticed its free shipping in Canada which is awesome! I'll check with my local hobby shop if they have it stock as well. Is there any sample code for this piece of hardware to help me understand how to code the alarm functions or read temperature? I want an LCD since to give both temperature reading and the current time. I do have a 4 -digit seven segment display but I think I'll need shift registers to save on pins possibly but it may complicate the design. I think going with a AC adapter and voltage regulator circuit is a good approach, also do you have any advice on how to set the time, should I do it via buttons and how? Thank you for advice and showing the site!
« Last Edit: July 02, 2013, 01:48:14 am by DanT29 » Logged

West Yorkshire, UK
Offline Offline
Edison Member
*
Karma: 40
Posts: 1204
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is there any sample code for this piece of hardware to help me understand how to code the alarm functions or read temperature?

I don't have any Arduino code, Dan, I used this RTC with a different micro-controller, but I will do my best to help. It was pretty straight-forward with the other uC, so I expect it will be easy with Arduino also. Google for the datasheet for the 3231 chip that the RTC uses. The datasheet is a long and complicated document, but don't worry. The only things you really need to know are the address that the chip uses on the I2C bus, and the locations of the registers for the day/month/year, hour/minute/second, temperature, alarm hours/minutes etc. They will be on a table on one page of the data sheet. Then read some of the Arduino tutorials on using the I2C bus (WIRE or TWI libraries) and ask any questions. I know all the theory, but not the details of how to do this stuff with Arduino, but I'm sure others will help. Also Google for "Binary Coded Decimal". You will need to understand that to write your sketch to set or read the time from the RTC chip.

I want an LCD since to give both temperature reading and the current time.

A 16x2 character LCD with an I2C interface may be your easiest option. You won't need any more pins at all, as both the RTC and the LCD can share the same connection to to the Arduino. They will have different "addresses" on the I2C bus.

I do have a 4 -digit seven segment display but I think I'll need shift registers to save on pins possibly but it may complicate the design.

You may not need a shift register for the LED display, or any other driver chips. Probably just 12 pins, using "multiplexing". Multiplexing is where it appears to the eye that all 4 digits are lit, but if you had a high speed camera you could see that actually only one of the 4 is lit at any one instant in time. This is a little more advanced technique from a programming point of view compared to the LCD, and its important to keep things simple for your first project, then build your skills up.

do you have any advice on how to set the time, should I do it via buttons and how?

You may not need to set the time again, once it has been set once, because the RTC is very accurate. Maybe a button to reset the seconds and minutes to zero once per year or so as needed. You will need buttons to set the alarm time, or maybe a potentiometer and a button to allow the user to "dial-up" the hours/minutes and press the button to enter.

Thank you for advice and showing the site!

That site is not the only one that sells that RTC. Check out eBay also. Shop around!

My advice would be to work on breadboards while you are working out your design. That's just because I happen to like them. I use the smaller ones that I can clip together into different configurations for each project. My first Arduino is a Nano instead of an Uno for example, so I can plug it straight into the breadboard.

Paul
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you Paul! I will try searching for that RTC, it seems to do all I want in one chip. I'll also look for an LCD with an I2C interface, I'm guessing there's cheap ones online. I like your idea of the potentiometer to dial through the numbers, it should save the user time from clicking. I would probably need help setting up the alarm set up but hopefully everything goes well. I'll keep you updated on which parts I ended up buying, probably order/buy them this week! I appreciate the help!
« Last Edit: July 02, 2013, 11:35:08 pm by DanT29 » Logged

West Yorkshire, UK
Offline Offline
Edison Member
*
Karma: 40
Posts: 1204
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This one is not i2c, but it does say it works with one of the Arduino libraries, so that may make things easier. Also has some buttons!

http://dx.com/p/lcd-keypad-shield-for-arduino-duemilanove-lcd-1602-118059

This one is i2c:

http://dx.com/p/funduino-iic-i2c-1602-lcd-adapter-board-w-2-5-lcd-screen-black-green-red-173588

And the rtc on ebay:

http://www.ebay.co.uk/itm/mini-RTCpro-DS3231-high-precision-clock-module-environment-temperature-measure-/390521397685?pt=LH_DefaultDomain_0&hash=item5aece3a1b5
« Last Edit: July 03, 2013, 12:16:16 am by PaulRB » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you for the links, just out of curiousity does first LCD (with buttons) you showed doesn't it only connect to the duemilanove board only or can the Uno work? I will be removing my microcontroller from my board so I can put on a smaller breadboard or solder it with other components. I want to keep the the arduino board as a programming circuit so I can just buy the microcontrollers that already have the bootloader (not sure if this is correct terminology). As for the I2C is there any references you have on how to make it work? I know its different from a regular one, from what I read finding the address is the hard part.

I also think this board is good, just need to solder headers in, its cheap too!

http://dx.com/p/16-x-2-character-lcd-display-module-with-blue-backlight-121356
« Last Edit: July 03, 2013, 12:57:52 am by DanT29 » Logged

Chicago
Offline Offline
Sr. Member
****
Karma: 5
Posts: 456
With every answer comes more questions.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


I also think this board is good, just need to solder headers in, its cheap too!

http://dx.com/p/16-x-2-character-lcd-display-module-with-blue-backlight-121356

This may be a better choice...
http://dx.com/p/arduino-iic-i2c-serial-blue-backlight-lcd-2004-module-display-138616

It already has the I/O expander attached and ready to go. (A way to control all 16 pins of display with just a few from Arduino.)
Logged

West Yorkshire, UK
Offline Offline
Edison Member
*
Karma: 40
Posts: 1204
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Dan, I don't think the duemilanove is any different to the uno, or most other arduino boards, when using components like lcds. I don't know why seller chose to mention that particular model, I suspect they dont know either!

That other lcd should be fine but will use more pins on the Arduino: probably 6 or 7 vs. 2 for i2c. This may nof be a problem for you. The lcd library will take care of the complex details for you, I suspect. There are also libraries for i2c and rtcs. But like I said before, I'm a newbie to Arduino too.

Paul
Logged

Pages: [1] 2   Go Up
Jump to: