NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Project Help and Ideas » PWM with multiple leds
September 22, 2009 by mcai8sh4 |
As some of you may know, I've made a binary clock - displays the time in a binary format by lighting up LEDs. It's been a while since I've altered anything on this, but I feel the need to change. Over the past couple of nights, I've been trawling through the ATMega datasheet, trying to decipher it's somewhat terse ramblings to reveal it's hidden treasure (well, I just want understand how to set up PWM), and I've managed to figure some of it out. I can now alter the brightness of LEDs on 4 (out of six) PWM channels - PB1, PB2, PB3, PD3 (I'll get the other two channels sorted eventually). Whilst I realize this is no great achievement (and quite unimpressive to watch) - I'm proud as hell. This is the first time I've managed to understand anything useful from the datasheet. But I digress... I want to now try my new found knowledge in a project - which brings be back to my clock. One of the things that concerns me is the power consumption of having those LEDs lit all the time. So my thought is thus : If I use PWM to dim the LEDs, will it increase the battery life (50% duty cycle = nominally 50% increase in battery life?) or will it make no real difference? If it will save the battery then my thinking is PWM oscillates a pin high and low very fast... on my clock, the led's all share a common ground (the blue rail) so when the PWM is low it will act like a ground - lighting my LED. This led to another thought - am I gonna break something if all my leds are connected to one PWM pin. Can the chip handle sinking that much? The most LEDs on at any one time would be 8 : example 11:31 = 1011 11111 Ideas/suggestions/insults/jokes welcomed. Thanks, Steve |
---|---|
September 22, 2009 by rusirius |
Steve,
I'm not an expert by any means when it comes to electronics, so take this with a grain of salt, or at least wait for someone else to back it up.. ;)
Actually I just thought of something... I believe the diodes are going to have a voltage drop across them too, so that would have to be factored in to the calculations... OR... As I recall reading about the AVR, You can "float" a pin when not in use.. That means it won't matter if it see's the 5v from the other pin, it won't sink or source any current... In that case you can eliminate the diodes altogether and won't have to mess with that.. ;) There.. problem solved... ;) |
Please log in to post a reply.
Did you know that the printf format string "%.3f" will show three digits after the decimal point? Learn more...
|