Arduino — Servo Sweep
Make a servo motor wave back and forth
Arduino
Servo
Sweep
Servo.h
What you will learn
- How the Servo.h library abstracts the PWM details
- How to attach() a servo to a pin and write() an angle
- Why a delay() between angle changes lets the arm actually MOVE to each position before the next one
What you will need
| Component |
|---|
| 1× Arduino Uno R3 |
| 1× servo motor (SG90) |
| 1× breadboard |
| 3× jumper wires |
Step by step
Take it further
- Add a potentiometer on A0 — turn the knob to control the servo angle manually (knob to angle).
- Add a button that, when pressed, makes the servo "wave" (rapidly go back and forth 3 times).
- Add a second servo on D10 and make them move in opposite directions (like a robot walking).
Practise it before you build it
Wire this circuit in the ThinkEdge Learn simulator first. The simulator runs a real Arduino sketch against a modified-nodal-analysis solver, so the LED on screen actually lights when the current is right — no hardware, no burnt components, and a class can try it in a browser.
Related projects
Servo — The Hello World of MotorsSweep back and forth forever
Servo — Two Buttons, Two PositionsPress A → go to 0°. Press B → go to 180°.
Arduino Nano — Reaction Timer GameHow fast can you press the button? Built in a tiny form factor.
Arduino Nano — 4-Note Mini PianoFour buttons, four notes, one tiny piano that fits in your pocket
Arduino Nano — Parking Sensor4 distance zones — 1 slow low beep far, 2 fast high-pitch beeps close (like a real car reversing buzzer)
Arduino Mega — 10-LED Bar GraphLight up an LED "bar" that grows with the analog input
Where this project sits
It is also part of these lists, which is how a class usually finds it.
Try the full simulator with your class
103 guided circuit projects, 21 lessons and an in-browser Arduino simulator. The first 15 projects are free, no account needed. One licence covers a whole school.