Hello,
I've just ordered a few kits but wanted to do some research... what kind of modifications would it take to be able to program the led's brightness to make them fade in and out for dynamic effects? Thanks
LED Fading
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
-
- Posts: 6
- Joined: Sat Feb 18, 2006 2:18 am
It should be possible to use pulse width modulation on the output lines if the processor is fast enough to acheive that effect. i.e. rather than providing the voltage to the LED continuously, cut it on and off very quickly.
And I saw some sample code for anti-aliasing on the site somewhere - this would have to use a similar effect.
And I saw some sample code for anti-aliasing on the site somewhere - this would have to use a similar effect.
-
- Posts: 21
- Joined: Sat Mar 12, 2005 4:55 am
This is somewhat suboptimal but should pretty much work:
Code: Select all
#include <avr/io.h> // this contains all the IO port definitions
void brightness(unsigned char on_time, unsigned char pattern) {
unsigned long int ii;
unsigned char timer;
for (ii = 0; ii < 80; ii++) {
PORTB = pattern;
for (timer = 0; timer <= on_time; timer++);
PORTB = 0x00;
while (timer) timer++;
}
}
int main(void) {
unsigned char on_time;
unsigned char pattern = 1;
DDRB = 0xFF; // set port B to output only
while (1) {
for (on_time = 1; on_time < 200; on_time += 1 + (on_time >> 4)) {
brightness(on_time, pattern);
}
for (on_time = 200; on_time > 0; on_time -= 1 + (on_time >> 4)) {
brightness(on_time, pattern);
}
pattern++;
}
}
-
- Posts: 21
- Joined: Sat Mar 12, 2005 4:55 am
Also the ATtiny2313 has PWM output driven by a specialized PWM driver, but I don't remember if you can get that guy to talk to the pins that are connected to the LEDs. I think his primary advantage is that you can (a) do something more important than count clock cycles for PWM and (b) do it when the CPU is in idle or power-down mode to reduce power consumption.
-
- Posts: 7
- Joined: Thu Feb 23, 2006 1:16 pm
Brightness
I would love to be able to control the brightness separate for each LED for mixing colors... 3 LEDs R G B and control there brightness to mix there colors.
kragen wrote:Also the ATtiny2313 has PWM output driven by a specialized PWM driver, but I don't remember if you can get that guy to talk to the pins that are connected to the LEDs. I think his primary advantage is that you can (a) do something more important than count clock cycles for PWM and (b) do it when the CPU is in idle or power-down mode to reduce power consumption.
-
- Posts: 21
- Joined: Sat Mar 12, 2005 4:55 am
Re: Brightness
Well, connect one output pin to R, one to G, and one to B, and you can do that. Check the specs on the B first --- does it require a higher voltage?pupdawg wrote:I would love to be able to control the brightness separate for each LED for mixing colors... 3 LEDs R G B and control there brightness to mix there colors.
Also, generally the 3-color LEDs have four leads, not six, so you may have to build a different circuit depending on whether it's common-cathode or common-anode.
-
- Posts: 7
- Joined: Thu Feb 23, 2006 1:16 pm
Re: Brightness
Yea the blue LED's I have use higher voltage.... I'm very very new to all this electronic stuff my background is in software devel. What I want to do it use ultra bright white LEDs with gels to make them colored and then use the tiny to do color mixing and other effects. I've managed to connect the tiny to terminal emulator and I am now writing a menu driven system for the LED's
kragen wrote:Well, connect one output pin to R, one to G, and one to B, and you can do that. Check the specs on the B first --- does it require a higher voltage?pupdawg wrote:I would love to be able to control the brightness separate for each LED for mixing colors... 3 LEDs R G B and control there brightness to mix there colors.
Also, generally the 3-color LEDs have four leads, not six, so you may have to build a different circuit depending on whether it's common-cathode or common-anode.
Please be positive and constructive with your questions and comments.