I'm trying to control an RGBW analog LED-strip by PWM modulation.

When using an Attiny45 the LED-strip just blinks at a low frequency (approx. 2-3 hz). However, using a Raspberry Pi 3 to control PWM works without a problem, and at any frequency of PWM I try.

Any ideas as to why that could be?

Additional information

In my test setup I power the Attiny45 by connecting to the 3.3V pin on the Pi (for now, will change later).

I have programmed the Attiny45 via SPI on the Pi using the Avrdude linuxspi module, following this instructable.

The setup is the same for both tested controllers:

The control pin with PWM output drives a MOSFET (IRLZ34NPBF), which connects one of the color leads on the strip to ground (which is connected to the Pi's ground).

An external power supply, rated for use with my LED-strip powers the strip, with the ground connected to the Pi's ground.

I have tried all different PWM frequencies on the Attiny45 (by default clocked at 8MHz, so I shouldn't even see a flicker on the lowest PWM frequency, which is 8MHz/(256*1024)=~30.5Hz (according to the official Datasheet, page 74)) and the same frequency on the Pi, which works without flickering.

The Attiny45 can drive a single LED using the same MOSFET setup without flickering.



simulate this circuit – Schematic created using CircuitLab

I tried adding a small value resistor (R1, 620Ohm) between gate and source of the MOSFET to counteract a floating state when the PWM is off, but it doesn't make a difference.

I'm looking forward to your input!

  • \$\begingroup\$ Are you confident the clock rates are programmed the same? \$\endgroup\$ Feb 20, 2019 at 1:10
  • \$\begingroup\$ Is there any difference in Vgs? >=4V is preferred over 3.3V \$\endgroup\$ Feb 20, 2019 at 1:27
  • \$\begingroup\$ "I have tried all different PWM frequencies on the Attiny45" - exactly how did you do this? \$\endgroup\$ Feb 20, 2019 at 5:39
  • \$\begingroup\$ @SunnyskyguyEE75 The Attiny45 has its fuses set to use the internal oscillator at 8mhz, using the formula given in the datasheet i calculated the pwm frequency. On the Raspberry Pi the PWM frequency can be set using the GPIO.PWM() setup function. Sadly, I can't measure the actual output because I don't own an oscilloscope... \$\endgroup\$ Feb 20, 2019 at 13:51
  • \$\begingroup\$ Also @SunnyskyguyEE75, the Raspberry Pi uses 3.3V on its GPIO pins, and since I power the Attiny45 off the 3.3V pin of the Pi it too uses 3.3V. I tried to power it off the 5V pin of the Pi, but that doesn't make a difference. \$\endgroup\$ Feb 20, 2019 at 13:57

1 Answer 1


Well, after some random tinkering I found that when I ground the attiny45 in a specific place on my breadboard setup it works without a problem. Therefore I think the problems I had had nothing to do with the chip itself, just some weird problem with my breadboard/jumpercables/etc..

Sorry for not trying that earlier and thank you all for your help!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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