Non working SoftwareServo library with ATtiny85 [SOLVED]

Greetings community!
I have a small problem with a project of mine. I am trying to create a servo controller with an ATtiny85, and what I have found so far says that I should use the SoftwareServo library.

I have downloaded this library and modified it so that it imports "Arduino.h".

For some reason, however, after I have loaded my ATtiny85 chips with the sample code, it refuses to do more than turn once or twice. It goes to the 180 degree position and then stops.

What am I doing wrong?

Thank you!

PS. Here is the code that doesn't work.

#include <SoftwareServo.h>

SoftwareServo servo1;

void setup()
{
  servo1.attach(1);
  servo1.setMaximumPulse(2200);
  servo1.write(90);
  delay(20);
  SoftwareServo::refresh();
}

void loop()
{
   int pos = 0;
   for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    servo1.write(pos);              // tell servo to go to position in variable 'pos'
    delay(20);                       // waits 15ms for the servo to reach the position
    SoftwareServo::refresh();
   }
  for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    servo1.write(pos);              // tell servo to go to position in variable 'pos'
    delay(20);                       // waits 15ms for the servo to reach the position
    SoftwareServo::refresh();
  }
  //SoftwareServo::refresh();
}

Are you sure the code is still running, ie, that noise on the power rail from the servo hasn't crashed the attiny? Are you running them off the same supply? If so, you need to take countermeasures against that - at a minimum, some caps for power filtering between supply and ground (I'd put one right next to the servo, and one near the tiny85). Often, people run servos and controller off separate supplies for this reason.

Post your schematic - did you remember the 0.1uF decoupling cap between Vcc and Gnd, which must be located as close to the tiny85 as possible? There are many low quality "guides" (which would be more aptly called "misguides") on the internet that omit this necessary component - without it, even without a noisey servo, the attiny85 can crash or reset itself seemingly at random.

I did not know that a 0.1µF capacitor was necessary. Thank you for pointing that out!

I have added the capacitor to the circuit, and the Tiny85 is no longer crashing randomly. It appears to be working just fine!

Thank you for the tip, Dr. Azzy!

PS. Should the capacitor be tantalum, membrane, or ceramic disk? I have all three types, and I would assume that a ceramic disk should work just fine. But I am new to this, so I thought I might as well make sure I do not use something completely wrong.

0.1uf ceramic for the bypass caps as close as possible to the tiny85 Vcc and ground pins.

Thank you very much.