Beginner Level: Single Servo Sweep

Beginner Level: Single Servo Sweep

animation
actuators
servo

Goal: Make a servo sweep smoothly from 0° to 180° and back, like a radar dish scanning.

Hardware: SG90 servo + ESP32

Code pattern:

for (int angle = 0; angle <= 180; angle++) {
  myServo.write(angle);  // Move to angle
  delay(15);             // Small delay for smooth motion
}

What to observe: The servo sweeps smoothly. Try changing delay(15) to delay(100) - notice the difference in sweep speed.

Back to the chapter