Servo — The Hello World of Motors
Sweep back and forth forever
Servo
motor
PWM
Sweep
What you will learn
- What a servo is and how it differs from a regular motor
- How PWM is used for servo control (different timing than LED dimming)
- How to make the servo sweep smoothly using a for-loop
What you will need
| Component |
|---|
| 1× 9V battery |
| 1× slide switch |
| 1× servo motor (SG90) |
| Breadboard |
| 3× jumper wires |
Step by step
Take it further
- Change the delay to 50 — the sweep is slower and smoother.
- Make the servo only sweep from 30 to 150 (a smaller range, like a real radar).
- Add a button — only sweep while the button is held down.
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
Arduino — Servo SweepMake a servo motor wave back and forth
Servo — Two Buttons, Two PositionsPress A → go to 0°. Press B → go to 180°.
Sound Sensor — Loud Sound LightLED brightness follows the sound · quiet keeps it off
Mini Ferris WheelA continuous rotation — the engineering of big wheels
Arduino Mega — 4-Servo Robot ArmDrive 4 servos at once for a pan-tilt-gripper-tilt arm
LDR — Automatic Night LightThe room gets dark, the LED turns on
Guides that use this project
12 guides on the site build this project as part of a longer explanation. The guide says why the circuit works; this page says how to wire it.
How to Build a DroneHow to build a drone from scratch: the four subsystems every drone needs, the parts that make them work, and the Arduino projects that teach each one before you fly.
How to Build a RobotHow to build a robot from scratch: one motor and a switch, then sensors, then a line-follower that steers itself. Every stage runs in a browser simulator first.
Robotics for BeginnersRobotics for beginners: five projects that take you from a blinking LED to a robot that steers itself, with the parts and the mistakes at each step.
Robot ArmHow to build a robot arm with hobby servos, a 5 V supply and an Arduino: how to pick joints, wire the power, and test each axis in the simulator.
Humanoid Robots: Balance First, Walking SecondWhat makes a humanoid robot work: inverted-pendulum balance, joint torque budgets and centre of mass, plus the Arduino projects to get you there.
Window Cleaning Robots: How They Stick to GlassHow a window cleaning robot grips glass with a vacuum fan, why the squeegee matters as much as the suction, and how to build the winch logic.
3D Printed Toys and ModelsWhich 3D printed toys make good classroom projects: designs with tolerances and moving parts, and the assembly and mechanism skills they teach.
Physical AI: Intelligence That Has to ActPhysical AI is intelligence that drives a motor, not a cursor. Here is how models, controllers and feedback split up, and how to build the loop safely.
arduino.cc and the Official Arduino Resourcesarduino.cc is the official Arduino site: the language reference, the board specs, the library registry and the free learning resources worth using in class.
UAV Drones ExplainedWhat a UAV is, how the main airframe types differ, and how a drone actually stays upright. The engineering behind drones, taught the way a student can build it.
FPV Drones ExplainedHow an FPV drone works: the camera, video link, goggles and flight controller that make it fly from the pilot's own point of view.
Sting Interceptor Drones ExplainedHow the Sting interceptor drone works: a small, fast, camera-carrying multirotor flown into a target by an operator. The physics, the engineering and the economics.
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.