Help with LED Lamp concept.

strykeroz:
Hi,

Just wondering what pin definitions you use in place of these on the ATTiny85 version?

// Output pins for PWM

#define  R_PIN  3  // Red LED
#define  G_PIN  5  // Green LED
#define  B_PIN  6  // Blue LED


As there is no D6 on that uC I'm hoping your ATTiny85 version was using 0, 1 and 4 (physical legs 5,6 & 3) which have hardware PWM support for that analogWrite() later in the sketch.

Cheers ! Geoff

Sorry I posted the sketch for the Arduino.

On the at85 I use 3,Red 0,Green 1,Blue.

kculm:
On the at85 I use 3,Red 0,Green 1,Blue.

Shuffle that red over to D4 and I think you'll have a better result. The tiny core doesn't give you hardware PWM control on D3 so the effect of analogWrite() will be a harsh cut-over from OFF to ON.

As identified above, you will still need to drive them using a transistor of some sort as (from page 166 of the ATTiny85 datasheet) the maximum power for any one pin is only 40mA so rather than sourcing the LED power from a pin you'll want to control it from a pin, and have the LEDs draw their power directly from a source that's attenuated by that transistor-PWM combination.

Cheers ! Geoff

kculm:
Darn, I spent all day reading up On NPN because I have a bunch.

Common-cathode LEDs cause these pains.

It's basically the same though, except the output will be inverted (pin LOW=LED on).

kculm:
First, Do i have to use Transistors? When I hook it up to My Arduino (with the right resistors) it works like a charm. But when i put it on a Bread Board with a atTiny85 and my DC power supply set to 5v. it works. Not a well, the transition are not as smooth. Is that because of the lack of transistors or is it the at85 .

The chip's I/O pins start to burn up at 40mA. There's no way you can drive six LEDs from one pin without damaging the chip (the effect you see is probably the chip fighting for its life).

kculm:
And lastly. will I need a resistor on the base pin of the PNP if so can you recommend the size.

Yes, and for the same reason: You have to keep the current coming out of the chip below 40mA.

330 ohms is a good general-purpose value.

can someone take a look at this before I burn something up.

Thanks

LED-Lamp1.jpg

strykeroz:

kculm:
On the at85 I use 3,Red 0,Green 1,Blue.

Shuffle that red over to D4 and I think you'll have a better result. The tiny core doesn't give you hardware PWM control on D3 so the effect of analogWrite() will be a harsh cut-over from OFF to ON.

Cheers ! Geoff

Thanks Geoff, But I have a question. The diagram http://www.akafugu.jp/images/microcontroller-reference-sheet.png it show PIN 3 as PWM. am I missing something as usual

thanks

all most there.

I have one last issue, When I run it with out transistors on the Arduino it works smooth. But when I use 3, PNP transistors it works fine up until the Green to Blue transition. It almost dims out completely then flicker to blue.

You can see what I am talking about here.- YouTube The first 45 sec our so is with out Transistors. After a few sec of blackness it with transistors.

Sorry for the poor video

kculm:

strykeroz:

kculm:
On the at85 I use 3,Red 0,Green 1,Blue.

Shuffle that red over to D4 and I think you'll have a better result. The tiny core doesn't give you hardware PWM control on D3 so the effect of analogWrite() will be a harsh cut-over from OFF to ON.

Cheers ! Geoff

Thanks Geoff, But I have a question. The diagram http://www.akafugu.jp/images/microcontroller-reference-sheet.png it show PIN 3 as PWM. am I missing something as usual

thanks

it is. It's just not usable as one in the Arduino IDE. use 4 and you'll be fine.

kculm:
Thanks Geoff, But I have a question. The diagram http://www.akafugu.jp/images/microcontroller-reference-sheet.png it show PIN 3 as PWM. am I missing something as usual

There's a hardware limitation: Pin 3 can only output the inverse of pin 4, pin 4 is the 'true' signal.

fungus:

kculm:
Thanks Geoff, But I have a question. The diagram http://www.akafugu.jp/images/microcontroller-reference-sheet.png it show PIN 3 as PWM. am I missing something as usual

There's a hardware limitation: Pin 3 can only output the inverse of pin 4, pin 4 is the 'true' signal.

While that's strictly true for the datasheet, in reply #38 of this thread on ATTiny85 and PWM Coding Badly explained that the inverted PWM output can't be used by the Arduino cores for ATTiny. My own testing confirms this gotcha - that D3 is not able to use hardware PWM with the arduino-tiny core. Software PWM like the tone() function works fine on all 5 of the standard ATTiny85 IO pins though, so there's an easy way around this limitation if you must use that leg.

Cheers ! Geoff

kculm:
I have one last issue, When I run it with out transistors on the Arduino it works smooth. But when I use 3, PNP transistors it works fine up until the Green to Blue transition. It almost dims out completely then flicker to blue.

You know the PWM is working so it has to be a power supply problem. You probably need some decoupling. Add ceramic capacitors between ground and 5V next to the transistors (as close as you can), see if that helps.

strykeroz:

fungus:
There's a hardware limitation: Pin 3 can only output the inverse of pin 4, pin 4 is the 'true' signal.

While that's strictly true for the datasheet, in reply #38 of this thread on ATTiny85 and PWM Coding Badly explained that the inverted PWM output can't be used by the Arduino cores for ATTiny. My own testing confirms this gotcha - that D3 is not able to use hardware PWM with the arduino-tiny core. Software PWM like the tone() function works fine on all 5 of the standard ATTiny85 IO pins though, so there's an easy way around this limitation if you must use that leg.

I don't know how the cores use the timers. I know that using hardware PWM on D3 and D4 at the same time wouldn't work for analogueWrite() functions.

fungus:

kculm:
I have one last issue, When I run it with out transistors on the Arduino it works smooth. But when I use 3, PNP transistors it works fine up until the Green to Blue transition. It almost dims out completely then flicker to blue.

You know the PWM is working so it has to be a power supply problem. You probably need some decoupling. Add ceramic capacitors between ground and 5V next to the transistors (as close as you can), see if that helps.

Thanks I will give that a try when I get home tonight. But so I am clear. I need to put a Cap from a Ground pin on the Arduino to the emitter on the PNP // Or is it from the Ground real to the 5v real.

And what size Cap.. ( Way to much to learn, I am glad it is fun).

Thanks

kculm:
Thanks I will give that a try when I get home tonight. But so I am clear. I need to put a Cap from a Ground pin on the Arduino to the emitter on the PNP // Or is it from the Ground real to the 5v real.

Between ground (any ground) and the 5V power line as close to the PNP as possible (touching it is good).

kculm:
And what size Cap.. ( Way to much to learn, I am glad it is fun).

0.1 ... 0.22 uF, that sort of size, but only ceramic type.

fungus:

kculm:
Thanks I will give that a try when I get home tonight. But so I am clear. I need to put a Cap from a Ground pin on the Arduino to the emitter on the PNP // Or is it from the Ground real to the 5v real.

Between ground (any ground) and the 5V power line as close to the PNP as possible (touching it is good).

kculm:
And what size Cap.. ( Way to much to learn, I am glad it is fun).

0.1 ... 0.22 uF, that sort of size, but only ceramic type.

I am using 3 transistors, so I am thinking one for each?

Also I cant thank you guys enough, I am learning so much.

kculm:
I am using 3 transistors, so I am thinking one for each?

At least! :slight_smile:

fungus:

kculm:
I am using 3 transistors, so I am thinking one for each?

At least! :slight_smile:

Did not help,

it works fine with out transistors. not as bright. and it only jacks up on the full blue to full green and full green to full blue.

kculm:
it works fine with out transistors. not as bright.

Has to be a power problem...how many mA are you using, how many are available.

kculm:
and it only jacks up on the full blue to full green and full green to full blue.

ie. At maximum current.

fungus:

kculm:
it works fine with out transistors. not as bright.

Has to be a power problem...how many mA are you using, how many are available.

kculm:
and it only jacks up on the full blue to full green and full green to full blue.

ie. At maximum current.

Right now I am testing it on an Arduino uno.

This is what I get. With out transistors it works fine. With Transistors is when I get the bule to green, green to blue issues.

If I use an at85 with out Transistors Is all jacked up, but with transistors I have the same issue as with Using the Arduino.

I have found another sketch but its not as nice, and I hate to just give up.

The green fades almost to nothing and the blue jumps on, if that helps any

kculm:
I have found another sketch but its not as nice, and I hate to just give up.

I can't see your circuit from here, unfortunately. Can you draw it?