-1
\$\begingroup\$

I'm pulling my hair out trying to get this ATtiny45 to work, hopefully someone out there can help.

The ultimate goal is to drive an RGB LED strip using PWM, but I'm getting some unreliable behavior from the ATtiny. To start, all I want is to blink a single LED on each of the three channels, pin5/PB0, pin6/PB1, and pin3/PB4. Right now the LEDs are connected directly from the pin to ground.

The problem: the board seems to reset itself, some times so fast the first LED just strobes, some times a second or two after the program starts. I have a 10k pull-up resistor on the reset pin(pin1/PB5), and have tried just connecting reset directly to Vcc. Nothing seems to make a difference. It seems to be worse when I add more LEDs.

The same program works fine when run on a full-sized Arduino UNO board, and it seems like the ATtiny has the program correctly downloaded. I tried a handful a of the ATtiny chips, and they all seem to behave similarly.

I'm pretty sure I got the chips from DigiKey, so I'm fairly certain that they are legit.

Any help would be very much appreciated.

\$\endgroup\$
  • 3
    \$\begingroup\$ Please upload your code, and a photo/schematic of your wiring. What LEDs are you using? Did you burn the bootloader on the chips? Also, if you are programming the Attiny with the LEDs connected to it, you will see rapid flashing on PB0 (MOSI) and I believe on MISO as well as the chip programs. Also you should have a current limiting resistor on your LEDs. \$\endgroup\$ – HavocRC Jan 31 at 3:15
  • \$\begingroup\$ You have not posted enough information about your LED strips. PWM is not used to drive RGB strips. RGB strips are almost always driven with serial data. PWM is built into the strips. On the strip there will be two power connections and a serial data in and serial data out. Tell me about your strips and then I can tell you how to drive them with an ATtiny. \$\endgroup\$ – Misunderstood Feb 5 at 3:06
1
\$\begingroup\$

If you have the LEDs connected directly to the IO pins, it is possible that your ATTINY is resetting because the supply voltage is dropping too low.

This could happen because when you turn on an LED, a lot of current flows out though it. This current has to come form the Vcc pin of the ATTINY. Pulling current from the power supply lowers the voltage, and if the voltage drops too low then the ATTINY will reset. When the chip resets, it turns of the LED and so the voltage goes back up and the chip starts up again and then turns the LED back on.... and the repeats - which would appear as a strobe.

To see if this is the problem, try connecting maybe a 100 ohm resistor between the chip pins and each LED. This should reduce the current significantly but hopefully still let enough current through that you can at least still see if the the LED is turning on.

If this does turn out the be the issue, then you need to make sure that the Vcc never drops below the chip's minimum voltage. How you do this depends on what kind of power supply you have, how long the LEDs are going to be on for, and how bright you need the LEDs - but could involve increasing your decoupling capacitor, stiffing up the power supply, quickly PWMing the LEDs (so they are not one long enough to pull down the voltage), or adding current limiting Resistors on the LEDs.

\$\endgroup\$
  • \$\begingroup\$ This seems to be the solution. I have been trying to drive an entire strip of LEDs through MOSFETs like this. I had a single power supply for the chip and LEDs, so I separated them using a separate supply for each. Looks to have done it! I haven't been using decoupling capacitors, but I will look into that as well. \$\endgroup\$ – Smithville Feb 1 at 2:56
  • \$\begingroup\$ Good guess! Are you psychic? I would have NEVER guessed that someone would try to driver a strip with an IO pin. The proper way to drive a string of RGB LEDs is to use a shift register LED driver circuit. PWM is not used to drive RGB strips, serial data is used to set the PWM of the LED itself or its driver (e.g. WS2812 or TLC5917). \$\endgroup\$ – Misunderstood Feb 5 at 3:00
  • \$\begingroup\$ You are thinking of addressable LEDs. The LEDs I am using use three digital signals: red, green, and blue. PWM controls the brightness. \$\endgroup\$ – Smithville Feb 9 at 1:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.