ATTiny with three PWM pins but without delay

Hello Everyone For a small project, I decided to use a ATTiny45-20 because of the size. The controller based on Arduino has to Power a 12V RGB-LED-Strip via three little MOSFETs. So i need 3 PWM outputs, but the ATTiny has only 2. Now I tried to create a manual PWM function with digitalWrite and delay/delayMicroseconds.Both of them with the delays worked fine but I dont want to use it because then I cant let them run at the same time for all three LEDs (rainbow-hueshift ). I tried to write it without delays:

void softPWMR(int freq) { // software PWM function that fakes analog output
  unsigned long cMR = micros();
  float durON = (freq*1000)/255;
  if((cMR - pMR > 1000-durON)&& r == 0) {
    digitalWrite(ledR, HIGH);
    pMR = cMR;
    r = 1;
  if((cMR - pMR > durON)&& r == 1) {
    digitalWrite(ledR, LOW);
    pMR = cMR;
    r = 0;

That's the code I tried to prevent using delays. But however I change the millis, micros and durations, I don't get a clear solution! Can someone help me or give me a hint? Thank you for everything and excuse me for my bad english. :~

helipla88: So i need 3 PWM outputs, but the ATTiny has only 2.

The ATtiny45 has three usable PWM pins. Whoever told you it has two is wrong.

Yes I saw this on a description of the seller but I didn't found out how to use three. On the internet, there are only two PWM pins (0 and 1) on some scematics and three analog inputs. I just tested them for PWM with analogWrite but didn't got any more PWM. Can you tell me which is the third PWM pin?

OK. Problem fixed. I just used another core ( and now it's working. Thank you for helfing me :)

You are welcome.

For the benefit of others, pins 0, 1, and 4 are PWM capable (physical pins 5, 6, and 3; B0, B1 and B4).