Electronic – LED-strip PWM works with Raspberry Pi, doesn’t work with Attiny45

attinyavrled strippwm

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!

Best Answer

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!