DIY Servo Tester – With The Junk You Already Have At Home
I have designed a simple circuit and wrote a simple sketch so that you can test your standard RC servos and center them for attaching the control horn – and the whole thing likely uses parts you already have in your electronics bin!
Here are the parts you will need: (note that unless you are using the PCB version of this – any RP2040 board can be used, I just quite like the RP2040-Zero) – most of these links are affiliate links and buying stuff after clicking these links may earn me a commission without increasing the price for you.
- RP2040-Zero:
- USA & World: https://amzn.to/3GjyOtO
- Canada: https://amzn.to/4ltXRuv
- Aliexpress: https://s.click.aliexpress.com/e/_oCasEUT
- Pin headers:
- USA & World: https://amzn.to/4lqaeI1
- Canada: https://amzn.to/4j3hQOU
- Aliexpress: https://s.click.aliexpress.com/e/_op2ch0R
- 5mm LEDs:
- USA & World: https://amzn.to/3E9pGHM
- Canada: https://amzn.to/4cG7zpG
- Aliexpress: https://s.click.aliexpress.com/e/_oC06nht
- Resistor set:
- USA & World: https://amzn.to/4cG7J0g
- Canada: https://amzn.to/4csDWIa
- Aliexpress: https://s.click.aliexpress.com/e/_opN73AL
- Terminal block:
- USA & World: https://amzn.to/42IyQ7i
- Canada: https://amzn.to/44qx3VM
- Aliexpress: https://s.click.aliexpress.com/e/_oCGeSin
- Tactile switch:
- USA & World: https://amzn.to/4luSdYU
- Canada: https://amzn.to/44o18VX
- Aliexpress: https://s.click.aliexpress.com/e/_okM0kAX
- Capacitors:
- USA & World: https://amzn.to/3YtyBuk
- Canada: https://amzn.to/3XY9T5j
- Aliexpress: https://s.click.aliexpress.com/e/_oFdBH0R
- Potentiometers:
- USA & World: https://amzn.to/4ifnOuK
- Canada: https://amzn.to/44nqRha
- Aliexpress: https://s.click.aliexpress.com/e/_oCpo3cB
If you want the PCB I would be happy if you ordered them from my long-term sponsor, PCBWay – but the truth is you can download the Gerber files on PCBWay’s site and get them made wherever you want:
PCBWay
Here is the schematic for putting it together:

Pin | Connection |
---|---|
0 | to servo signal wire (typically white or yellow) |
1 | to positive (anode) of a LED via a dropper resistor |
2 | to positive (anode) of a LED via a dropper resistor |
3 | to positive (anode) of a LED via a dropper resistor |
4 | (PCB ONLY) to positive (anode) of a LED via a dropper resistor |
5 | (PCB ONLY) to positive (anode) of a LED via a dropper resistor |
8 | to push button connected to ground |
26 | to wiper of a potentiometer |
5v | to 5v power (or use USB) |
GND | to ground |
Here is the code which should be compatible with any RP2040 board in the Arduino IDE – you may want to check the github for the most up-to-date code but since GitHub isn’t beginner friendly – here it is for you to copy/paste:
/*
This code is written by Simple Electronics (https://simpleelectronics.ca) & (https://youtube.com/simpleelectronics) and has been
tested to work as-is - but please feel free to make your own improvements!
ChatGPT was used as a rubber-ducky and did not wholesale write this code - Dan from Simple Electronics did.
Feel free to distribute as you wish - this was meant to help people who can't code well achieve their goals.
*/
#include <Servo.h> // Library needed to handle servo movement
Servo servoOne; // Creating a specific servo "object" - this is from the Servo library
int servoPos = 0; // This variable will output the requested angle for the servo
int potPos = 0; // This variable will track the position of the wiper of the potentiometer
int modeSelect = 1; // This variable will track which mode we are in - pot control, centering, sweeping
int incrementDir = 1; // This variable will be modified to increment or decrement the servo angle
const int potPin = 26; // Sets GP26 to the wiper of the potentiometer
const int selectPin = 8; // Sets GP8 to the button we will use to toggle the mode of the program
const int modeOne = 1; // Sets GP1 to be our mode 1 indicator LED driver
const int modeTwo = 2; // Sets GP2 to be our mode 2 indicator LED driver
const int modeThree = 3; // Sets GP3 to be our mode 3 indicator LED driver
unsigned long lastPressTime = 0; // This variable allows us to track the time since the last button press
const int debounceDelay = 100; // Settable delay to debounce the switch - 100ms debounce as default
void setup() {
servoOne.attach(0); // Attaches the servo "object" to pin GP0
pinMode(selectPin, INPUT_PULLUP); // Activating the pullup resistor on the input pin - only needed to activate the resistor
pinMode(modeOne, OUTPUT);
pinMode(modeTwo, OUTPUT);
pinMode(modeThree, OUTPUT);
}
void loop() {
// This block deals with the mode selection - essentially, when the modeSelect is 1, the program is in center mode, 2 is sweep and 3 is potentiometer control
if (digitalRead(selectPin) == LOW){
if (millis() - lastPressTime > debounceDelay) {
lastPressTime = millis(); // Update last press time
modeSelect++;
if (modeSelect > 3){ // We only have 3 modes, so we want to have it cycle instead of incrementing forever
modeSelect = 1;
}
}
}
if (modeSelect == 3){
digitalWrite(modeOne, LOW); // Block of code to turn on only our selected mode indicator LED
digitalWrite(modeTwo, LOW);
digitalWrite(modeThree, HIGH);
potPos = analogRead(potPin); // Reads the position of the potentiometer and stores the value
servoPos = map(potPos, 0, 1023, 0, 180); // Converts the analogRead values (0-1023) to a servo angle (0-180)
}
if (modeSelect == 1) {
digitalWrite(modeOne, HIGH); // Block of code to turn on only our selected mode indicator LED
digitalWrite(modeTwo, LOW);
digitalWrite(modeThree, LOW);
servoPos = 90; // Sets the servo to center position when in this mode
}
if (modeSelect == 2) {
digitalWrite(modeOne, LOW); // Block of code to turn on only our selected mode indicator LED
digitalWrite(modeTwo, HIGH);
digitalWrite(modeThree, LOW);
servoPos = servoPos + incrementDir; // Creates a sweep of the servo arm
if (servoPos >= 180 || servoPos <= 0){ // When the servo position is over or under the minimum and the maximum, flip it the other way
incrementDir = -incrementDir;
}
}
servoOne.write(servoPos); // Outputs the servo position in degrees (0-180)
delay(15); // This delay allows the servo time to move - adjust this at will.
}
Here is the GitHub link: https://github.com/SimpleElectronicsYT/Servo-tester
Happy Servo-ing!
0 Comments