#include <Servo.h>
Servo myServo; // Menggunakan huruf kapital "S"
int pos = 0;
void setup() {
myServo.attach(3);
}
void loop() {
// Maju dari 0 hingga 180
for (pos = 0; pos <= 180; pos += 1) {
myServo.write(pos);
delay(5);
}
// Mundur dari 180 hingga 0
for (pos = 180; pos >= 0; pos -= 1) { // Memperbaiki di sini
myServo.write(pos);
delay(5);
}
}