I have an ATTiny85 with a PWM output (freq. aprox. 1kHz). Connected to this pwm output pin is a NPN general purpose BJT (2N2222) with base resistor of 1k. A LED is in series with this transistor (before the collector). The LED has a current limiting resistor of 470R.
Everything seems to work pretty good, but if my PWM duty cycle is very low (< 30%), then something strange happens. Every few seconds the LED flashes/flickers. But it's not the well known PWM flickering. My flickering is very irregular (just every few seconds).
I used a oscilloscope and did some probing. The PWM output signal directly at the microcontroller pin was ok in my opinion. Then I checked the conductivity of the transistor, connecting my scope probes to the vcc and emitter of the transtistor. This gave me the following result (see picture).
Am I correct, the the transistor is not properly switching off, and "skips one cycle"? This could be the reason, why the LED flickers?
Now the most important questions: Am I using the wrong transistor type - or should I switch to a mosfet-based solution? What would you suggest, to solve this issue?
Thank you very much. You help is greatly appreciated!