#include <Servo.h>
Servo myservo;
int a = 0, b = 1;
long time = 0;
bool c = true;
void setup() {
Serial.begin(9600);
myservo.attach(11);
myservo.write(0);
}
void cool() {
Serial.println(a);
myservo.write(a);
time = millis();
}
void loop() {
if (c == true && millis() - time >= 20) {
a += b;
cool();
}
if (a >= 135) {
c = false;
}
if (c == false && millis() - time >= 20) {
a -= b;
cool();
}
if (a <= 45) {
c = true;
}
}