Let's Make Robots! | RobotShop

Micro Servo Robot

MiniRobot_1_3.ino_.zip2.73 KB
MiniRobot_1_3EN.ino_.zip3.52 KB
Micro_Servo_Robot_Flowchart.pdf84.04 KB
Micro_Servo_Robot_Diagramm.pdf74.13 KB

4 axis robot arm with a small gripper and teach function. (In fact: it is a 3 axis robot)

This robot can follow. This robot can learn. And this robot can repeat endles. And he lost all his memory if the batterys are low. This makes it new all the time he is powered again. - The idea for this project is taken from https://www.robotshop.com/letsmakerobots/node/21633 - Stoerpeak made me do it! -

Arduino mini pro 5V/16MHz

4 micro servos 180degrees

4 22k potentiometer

NmH Battery 4.8V

Wires, Button, Switch

Balsa wood, Metal, Plastic

Zip Ties and Glue


Teach mode: After a reset the robot arm follows the teach in arm while simple mapping the analog inputs every 25ms to the servo motors. Pressing the button stores each servo position in a array

Play mode: Double press the button switch to play mode. The sketch reads the array step by step and and moves the robot arm. For cool loocking movements i added a routine calculates different micro steps for each servo to have moving start and end sync on all axis. Also added a ramp for soft increase/decrease velocity. Shorter travel distances the robot does slow, longer distances with faster speed. Its all about timing so my thoughts in this moment

Play Mode version 1.1 The gripper input is used to set the delay (0,1,3,15,60,300 seconds) after a loop is done. The switch (it was left from the project start) pauses the robot

08/2015 i added the same code 1.3 but i try add english comments

10/2015 flowchart for the code and electrical diagram. (make sure you use a pullUp resistor at input 4,6 / change the code for input 4. This should fix the 'slow running problem' often happend)


Hey people!!: If u share my code please keep decency and give me credits. And dont forget Stoerpeak!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

The line of code in bold will speed up playback, but I think it causes other problems. I havent fully tested it, and I think it affects the movement accuracy of the shoulder servo. But it is nice to see some playmode speed. Try teaching a loop that doesnt use shoulder movement. A better/different solution is definitely needed.  Also, its possible that a reset is needed to teach a new loop. Seems like previous loop movements can show up in a new loop.

void calculate()
      dif[0] = abs(ist[0]-sol[0]);
      dif[1] = abs(ist[1]-sol[1]);
      dif[2] = abs(ist[2]-sol[2]);
      dif[3] = abs(ist[3]-sol[3]);
      stepsMax = max(dif[0],dif[1]);
      stepsMax = max(stepsMax,dif[2]);
      stepsMax = max(stepsMax,dif[3]);
      stepsMax /= 12;


This is awesome man. This did work on my robot. I have a question though, what other problems is it creating for you?

I'm finding an issue that after the playback is finished it does not repeat again, and the led remains blinking. Has someone experienced this?

your gripper potentiometer is in 'delay position'... ;-)

You rock man!

dif[4], ist[4], sol[4],  dir[4]; for example what is that? what is it work ? Could you Explain line by line the code ? I done everything its work but ı wanna understand the code.

this are arrays for servo 1-4 ( and short words from german. sry but while write the code dident had the idea i share it one day)

ist = momentary position from a servo

sol = next position the servo should go

dif = the difference from 'momentary' to 'should be' position

dir = the calculated step-with for a single step a servo does. This step will be done in a loop for 'stepsMax' times. With this 'micros steps' all servos are at same time at the new position. 


Hi, thank you for sharing!

Where did you buy this potentiometers? I can't find nothing like yours potenciometers.


Thank you in advance!

Hi Pinaut I really like your robot and would like to recreate one myself as my first robot. I'm having a bit of trouble understand how you put the circuit together for the teach function, you think you could share some wisdom with me?

+5V and GND to the pin 1 and 3 from the potentiometer(s). The middle pin 2 goes to the analog IN from the arduino.

https://www.arduino.cc/en/Tutorial/Potentiometer ;-)