Introduction: Simple 12 Channel Servo Tester - Project InMoov Dumb-Controller

I built a very simple and cheap servo tester using an Arduino Mega, an Arduino Mega Servo Shield, two push-buttons and a potentiometer. I built this servo tester for my InMoov so I don't have to unplugged the servo Ich want to evey time.

You can find out more about this Project and more content (reviews, tutorials, projects, etc.) on homepage:

Ni-TEC

This is the most simple way to built a multi-channel servo tester. Revision 2 will use an Arduino Mega2560 Pro, a breakoutboard and an OLED screen (I am still waiting for the parts from china, may take away few months). The BOM for the simple REV 1 servo tester is:

1x Arduino Mega 2560

1x Arduino Mega Servo Shield

1x Potentiometer

2x Push-buttons

Some wires

2x 10k resistors

The wiring is very simple. Just follow the wiring Diagramm. And remember: wire the potentiometers and push-buttons VCC Pins to a 5V source (from the shield) and not directly from your power source. The Power source may be >5V and fry your Arduino! I also had to insulate the bottom pins of my high quality china Shield...they would contacted the Arduinos USB plug and fry the board. You can also use an Arduino UNO (and change the pins in the Code) if you desire.

Step 1: Assembly and Wiring

First push the Shield firm into the Arduino MEGA 2560. Then you need to Wire everything up. Wire one pin of each button and one outside pin of the potentiometer to VCC 5V. Wire the other outer the potentiometer pin to ground. Wire one Pin of each push button to ground using a resistoe. Be sure to check which pin of the push buttons you wire in which was using a multimeter. I wired everything up using a cheap PCB.

At last wire the signal pin of the push buttons to digital pins 52 and 53. Wire the potentiometers wiper pin to A0. I used hot glue to fix the potentiometer and the push buttons on the bottom of the Arduino.

Step 2: Code

You can just copy & paste this code to the Arduino IDE andere upload it to the Arduino MEGA.

The code works simple. With the buttons you select which servo channel you want to use (2-51). With the potentiometer you can turn the servo. You can code software min- und max-positions using the table / matrix at the beginning. You have to include the servo.h library in your code. You can do this manual or just copy the code via the link to pastebin.

I know this servo tester is not perfect. The biggest problem for me is the missing channel indicator. But Always remember: you can reset the Arduino to the first channel using the RESET key.

A tutorial for a version with a display is coming up as soon as I recieve my parts from China.

Code in Pastebin

//min and max position for each of the 50 servo channels, each line consists of 10 channels
int min_max[51][2]  = {
  {0,0}, {0,0}, {15,170}, {0,180}, {0,180}, {0,180}, {0,180}, {0,180}, {0,180}, {0,180},
  {0,180}, {0,180}, {0,180}, {0,180}, {0,180}, {0,180}, {0,180}, {0,180}, {0,180}, {0,180},
  {0,180}, {0,180}, {0,180}, {0,180}, {0,180}, {0,180}, {0,180}, {0,180}, {0,180}, {0,180},
  {0,180}, {0,180}, {0,180}, {0,180}, {0,180}, {0,180}, {0,180}, {0,180}, {0,180}, {0,180},
  {0,180}, {0,180}, {0,180}, {0,180}, {0,180}, {0,180}, {0,180}, {0,180}, {0,180}, {0,180},
};
Servo myservo;
int forwards_state = 0;
int old_forwards_state = 0;
int backwards_state = 0;
int old_backwards_state = 0;
int channel = 2;
int i = 2;
int val;
const int forwards_pin = 53;
const int backwards_pin = 52;
const int pot_pin = A0;
void setup() {
   pinMode(forwards_pin, INPUT);
   pinMode(backwards_pin, INPUT);
   pinMode(pot_pin, INPUT);
   Serial.begin(9600);
   do {
   pinMode(i, OUTPUT);
   i = i+1;
   delay(1);
   } while (i <= 51);
}
void loop() {
  forwards_state = digitalRead(forwards_pin);
  backwards_state = digitalRead(backwards_pin);
  if (forwards_state != old_forwards_state && forwards_state == true){
    if (channel < 51) {
    channel = channel+1;
    } else {
    channel = 2;
    }
  } else if (backwards_state != old_backwards_state && backwards_state == true){
     if (channel > 2) {
    channel = channel-1;
    } else {
    channel = 51;
    }
  }
  old_forwards_state =  forwards_state;
  old_backwards_state = backwards_state;
  
  val = analogRead(A0);
  val = map(val, 0, 1023, 0, 180);
// constraint servo angles within the min_max positions defined above
  if (val > min_max[channel][1]) {
    val = min_max[channel][1];
  } else if (val < min_max[channel][0]) {
    val = min_max[channel][0];
  }
  myservo.attach(channel);
  
  myservo.write(val);
//  myservo.detach();
    
  Serial.println(channel);
  delay(5);
 
}