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();
}