I need some advice on how to control 14 leds, with the smallest possible microprocessor. I'd rather not buy an arduino mini just for this project, as this is a school project. I haven't written any code yet, but I was thinking I could just count the time within the loop.

I discovered that it is possible to shrink your projects, by uploading your sketches into single chips, such as the ATtiny85. Now that's small enough, but it only has 6 I/O pins, and I need to control 14 leds. Unless I can find a 14 I/O chip that's relatively small, I'm going to need some help from you guys. I googled around and read something about an LED matrix, but I really don't get the idea, since it seems to require the same amount of outputs anyway. I guess it makes the code clearer.

TL;DR: What's the simplest way of controlling 14 LEDs with the smallest possible configuration?

Thanks, but isn't the the ATmega series quite large, compared to Attiny? ATtiny 40 seems to have a max 18 I/O pins and it's definetely smaller. Do I need the crystal and caps if I'll end up using this one? What about the program to turn the leds on, can you suggest anything "smoother" than a bunch of if - structures?

Thanks, but isn't the the ATmega series quite large, compared to Attiny? ATtiny 40 seems to have a max 18 I/O pins and it's definetely smaller. Do I need the crystal and caps if I'll end up using this one? What about the program to turn the leds on, can you suggest anything "smoother" than a bunch of if - structures?

The smallest one with 14 pins would be an ATtiny4313.

PS: You don't really need the crystal, they work just fine with their internal clock. The only time you need an external crystal is when you need accurate timing for, eg. serial communications.

If you want a smaller AVR chip (Tiny84 or Tiny85) then you'll need an external 16 channel LED driver. I think the smallest 16 channel chip has 24 pins (eg. TLC5925).

Right, that's pretty obvious. I've got a friend who has an Uno, so I can program the chip with it, right?

You can do it that way So long as he doesn't mind you pulling it apart. The best way to work with bare chips is to get an "ISP Programmer". They cost about $12 and when you have one you don't lose any flash memory to bootloaders, etc.

PS: The ATtiny85 only really has five usable pins. You can use six pins but after you reconfigure the reset pin for I/O you can't upload any more software without a special device to configure it back again.

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Using charleplexing, you can control up to 20 LEDs with 5 pins. This would be your best bet. I recently put some code up on Github that makes it relatively painless: https://github.com/marcuserronius/ChuckPlex/tree/1.0

… as for controlling the LEDs, I'd make arrays organizing the relevant LEDs. Split the time up into separate decimal components, and extract the extract the place values of the ON bits from each, use them as indices for the LEDs array, i.e.:

Something like that, maybe. If you go with multiplexing the LEDs, this *might* end up causing too much flicker, in which case you could build a list of LEDs to turn on and cycle them until the next time the time changes.

As you are building a BCD clock I would use an ATTiny with at least 8 outputs and arrange your leds on a 4x4 grid (with gaps where you dont need LEDs)

Then you can use 4 of your outputs for your rows and four for you columns and you have an easier solution than charlieplexing. You would need to row scan the rows of the 4x4 matrix but there are loads of tutorials on how to do that on these forums and on the net.

An RC oscillator isn't going to make a very accurate clock... Not at all. Go read the notes on RC frequency vs temperature and supply voltage variations. What you propose to do would be neat... as long as it didn't have to keep time.

Bob

--> WA7EMS "The solution of every problem is another problem." -Johann Wolfgang von GoetheI do answer technical questions PM'd to me with whatever is in my clipboard

Alright, hope this post isn't too old yet, because OP is here to deliver... Somewhat.

So I got this set up on a breadbord with the Arduino Uno, just to see how the code works. I'm using the millis() function to count milliseconds from the time when the program started. Every 1000 milliseconds, it adds one to seconds, every 60 seconds it adds one to minutes and so on. Each LED is connected to it's own digital pin on the Uno and lights up accordingly with basic if functions. Right now there's only one button to set minutes on digital pin 0, but I plan to add one for hours as well when its time to shrinkify this project to the ATtiny2313. The reference page says that this millis() function overflows after approximately 50 days, how badly does this affect the clocks accuracy?

I'm building the schematic with Eagle now. Do I need any other components, suchs as caps, in order for the ATtiny to work properly?

I tried something with using millis() to run a clock. That had a longterm drift (a minute or so every day). That was with an (older) Arduino with a crystals - the newers ones have something else that is not as regular.

Get an RTC chip, maybe on on a breakoutboard w/battery, and use it. (I dont know if you can get something that will interface easily with the ATTiny). By the way, I could set the 24 hour clock using just one push button (and some patientence)

Well patience... doesn't quite belong in my vocabulary. Besides, it isn't very convenient if you have room for two buttons. I'll be setting the time in the code anyway before I upload it. I'm adding the button mainly for demonstration.

You will need to (re)set the time sometime. Daylightsaving f.ex. Or a powerloss, battery change. The "patience" was that my little onebutton algorithm involved waiting for a few secs for it to advance to the next digit and entering 9 required - yes, nine pushes.

You will need to (re)set the time sometime. Daylightsaving f.ex. Or a powerloss, battery change. The "patience" was that my little onebutton algorithm involved waiting for a few secs for it to advance to the next digit and entering 9 required - yes, nine pushes.

Oh, I thought you meant pushing the minute button 60 times to advance one hour Well, that's convenient enough. May I ask how did you do it?