Controls
Dial-controlled pointer
Turn a dial and a servo arm follows it through half a circle. The start of a gauge, a robot arm or a small gate.
- Medium
- about 25 min
- Arduino Uno
- No soldering
- 6 parts
- 6 wires
- 18 lines of code
Opens this circuit, already wired, with the sketch loaded. Free, nothing to install.
Idea
A servo does not spin freely: it turns to the angle you ask for and holds it. Here the dial chooses the angle, so your hand moves the arm from a distance.
What you learn
Using the Servo library, and mapping a reading of 0 to 1023 onto an angle of 0 to 180.
How it works
input
Dial (potentiometer)
decides
Arduino Uno
output
Servo arm
Powered with 5 V from the Uno's USB cable. No battery and no soldering.
This circuit and sketch are run in the ManuStem simulator before the pack is published. Real parts vary between makers: follow the labels printed on your own module, not its position in the picture.
Parts
0 of 6 ready
No prices here: they change by shop and by week. Buy each part by its name and the note beside it.
You also need
A computer with Arduino IDE 2 installed (free)
3D wiring
One jumper per step. Unplug the USB cable while you wire.
Step 0 of 6
Lay out the parts
Push the small parts into the breadboard as shown. Nothing is connected yet.
All connections
servo-pointer.ino
// Dial-controlled pointer
// ManuStem Build Pack: https://stem.manusignal.com/packs/servo-pointer
#include <Servo.h>
const int SERVO_PIN = 9;
const int DIAL_PIN = A0;
Servo arm;
void setup() {
arm.attach(SERVO_PIN);
}
void loop() {
int angle = map(analogRead(DIAL_PIN), 0, 1023, 0, 180);
arm.write(angle);
delay(15);
}
Libraries
- Servo.h: comes with the Arduino IDE.
Uploading
- Open the sketch in Arduino IDE.
- Plug the Uno in with the USB cable.
- Tools > Board > Arduino Uno, then Tools > Port and choose the board's port.
- Press Upload (the arrow). Wait for “Done uploading”.