Servo — Two Buttons, Two Positions
Press A → go to 0°. Press B → go to 180°.
Servo
Button
If/Else
What you will learn
- How to combine digital inputs with actuator outputs
- How servo.write() is "set and forget" — it stays at that angle
- How real-world buttons, switches, and remotes are just digital inputs
What you will need
| Component |
|---|
| 1× 9V battery |
| 1× slide switch |
| 2× pushbuttons |
| 1× servo motor (SG90) |
| Breadboard |
| 6× jumper wires |
Step by step
Take it further
- Add a third button that sends the servo to 90° (the middle).
- Make the servo move SLOWLY toward the target with multiple intermediate writes (like animation).
- Print the current angle and which button was pressed to the Serial Monitor.
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
Arduino — Servo SweepMake a servo motor wave back and forth
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 — Two-Player Reaction BattleTwo players, two buttons — fastest finger wins
Binary Counter — How Computers CountFour LEDs, sixteen numbers — counting in twos
Guides that use this project
One guide 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.
Where this project sits
It is also part of these lists, which is how a class usually finds it.
Arduino servo motor projects for students12 projects in this list
Arduino push button projects for beginners14 projects in this list
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.