How to choose the microcontroller

Hi all!
I've built a portable Arduino project, but now I need to build a simple portable clock with a 4 digits 7 segments display and an rtc (DS1307).
On the web I found many guides that explain how to build your own board, and many describing the steps to take to select the best micro for every situation, but I can't understand a thing: how do I know that I can send code to that controller using the Arduino IDE and my Arduino UNO board?

Thank you guys, you're awesome!

Hi Deadalus,

You could use almost any attiny or atmega and use your arduino to program it. First get the clock working with your Arduino, then swap in your new chip and use Arduino with the arduinoISP sketch to program it.

For this project, an external crystal won't be needed.

I would recommend an atmega328 and drive the display directly with a few transistors to boost the current.

Alternatively, use an attiny85 and a separate driver chip for the display, like saa1064.

Paul

Thank you PaulRB for your reply

One more question, in which case should I use an external crystal?

You would need an external crystal for the microcontroller chip for 2 main reasons. First, if you need maximum processing speed. You can get an attiny or atmega up to 16MHz or even 20MHz with an external crystal. Without you can only go at 1MHz or 8MHz, but that be more than fast enough for a clock project. Secondly, use a crystal if you need the microcontroller to talk to other chips or circuits that need very accurate timing. Your clock project won't need this because the 1307 rtc will be keeping accurate time.

However, the rtc chip will need an external crystal (for the second reason above) but if you buy an rtc module, it will have a crystal built in, and a small battery so that the time is not lost when the main batteries go flat.

What kind of 7 seg display will you choose?

I already have a 4 digits display, the one with one dot per digit, not 2 in the middle (that would be perfect for a clock). It uses 12 pins.
I also already have the DS 1307. Had to make the ebay seller to send me another one 'cause the first had a problem with the battery power supply (got it replaced free ofc).

I'm also considering to use some LEDs (rencetly bought a 1k pack :D) and make a binary clock, since I have very little space available, and the 4 digits display isn't even that good looking, whereas I can give LEDs any layout.
But I would still need at least 10 pins down from 12.

I'm now looking at this list. Do I have to care about some specifics to make my rtc work using the i2c? (I don't even know what it is... xD)

I would not worry about all the different versions on that list. There are really only about 3 or 4 you should consider for your project:

ATTiny85 - 8 pins (or maybe ATTiny45 which has less memory)
ATTiny84 - 14 pins (or maybe ATTiny44 which has less memory)
ATTiny4313 - 20 pins
ATMega328 - 28 pins

Any of the above is capable of interfacing to the ds1307 with I2c.

If you choose one of the ones with few pins, you are going to need an extra chip to drive the displays. The 20 pin is not much smaller than the 28 pin, so that's why I would recommend the 328. You then have enough pins for displays, a few buttons etc. Plus its the same chip as an UNO, so your sketch will need very few changes, if any, to run on it.

You might also want to consider an LDR so you can make the display brighter or dimmer depending on how bright the room is, and a piezo sounder so you can make an alarm or chimes. You could also use 6 leds to show the seconds in binray, while the 7-seg display shows the hours & minutes.

Question: if you don't know anything about i2c, how did you realise your rtc was faulty?

PaulRB:
Question: if you don't know anything about i2c, how did you realise your rtc was faulty?

Because every time I disconnected it from the UNO, even if it had the battery it stopped counting seconds, remaining fixed on the time it was disconnected, to restart counting time the moment it was reconnected to the Arduino =)
Always about I2C, does it work on any μC or is there a feature/sign I have to search for when I need to know if it is supported?

Back to the choice, thank you for your suggestions! I think I'll go for the 328, so I'll be able to add a couple of features.
Last thing: looking on ebay there are many versions of the same uC. Do I have to look for or avoid something?
Also, what's the difference betwenn the square and rectangular, only shape and replacement difficulty?

EDIT: e.g. square and rectangular

Thank you very much for your time!

That is strange! I had a faulty ds3107. It would reset back to 00:00:00 when disconnected from external power. It did not freeze and continue from the previous time. I wonder if it was truly faulty, or could have been corrected by adjusting its control registers. Oh well, you have a working rtc now, so it does not matter.

Most microcontrollers will have an i2c capability.

Here is the important advice. GET THE 28-PIN DIP (the rectangular one) NOT THE SQUARE ONE! You will not be able to use the square one on your breadboard. Those are for advanced hobbyists who can make and solder surfface mount components.

But don't get the uC yet, prototype the whole project using your UNO and breadboard first. You can get 95%+ working before you need the other uC.

Paul

Ok then I'll buy a 328P-PU, same version mounted on my Arduino UNO R3 =)

Thank you again man!

No problem. Good luck. Come back if you have more questions. I'll be interested to see how it turns out.

Paul