Robotic Piano Player





Introduction: Robotic Piano Player

Made a simple robotic one finger piano plinker using two servos, Arduino Uno, some aluminum flashing and a fishing pole for the sliding rails. You get a gold star if you can identify the ditties it plays. You probably have to be an old person like me to know a couple of them.

Step 1: Fishing Pole Rails to Slide Finger On

Used a fishing pole and cut a couple of short sections to slide outside two longer pieces. Then epoxied them too some wood connectors. Connected the two outside sliding pieces with a wooden platform on which is mounted the aluminum holder of the finger servo.

Step 2: Built "finger" From Chopsticks

Made a single joint finger from chopsticks and mounted that to a servo.

So one servo for the finger and one standard size servo for the slider.

Step 3: Connect Servos to Arduino

Connect two servos directly to Arduino Uno 5vcc,gnd and signal pins 9 and 11.

Run Arduino sketch as follows:

#include servo.h
Servo servo1,servo3;

int ledPin = 13; // select the pin for the LED

void setup() {


pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT



servo1.write(110); // put finger at starting position



servo3.write(71); // position slider at starting position

delay(5000); // wait 5 seconds before beginning


void playKey(int slidePos) {

servo3.write(slidePos); // move slider servo to key position

delay(300); // give slider time to get there

servo1.write(85); // move finger down and press key

delay(100); //give time to move finger down

servo1.write(110); //pick finger back up

delay(300); //give time to pick finger up before next slider move


void loop() {


/* playKey(165);//f delay(500); playKey(149);//g playKey(138);//a playKey(127);//b playKey(116);//c playKey(105);//d playKey(94);//e playKey(83);//f playKey(72);//g playKey(61);//a playKey(50);//b playKey(28);//c playKey(15);//d */

// cetk //

playKey(71); playKey(60); playKey(83); playKey(170); delay(400); playKey(116); delay(2000);

// avengers //

playKey(72); playKey(94); playKey(83); playKey(50); playKey(15); playKey(28); playKey(72); playKey(94); playKey(83); delay(2000); //amazing grace playKey(160); playKey(116); playKey(94); playKey(94); playKey(105); playKey(116); playKey(138); playKey(149); delay(2000);

//indiana jones

playKey(138); playKey(127); playKey(116); playKey(83); delay(500); playKey(149); playKey(138); playKey(127); delay(500); playKey(116);//c playKey(105);//d playKey(94);//e playKey(50);//c playKey(105);//d playKey(94);//e playKey(83);//f playKey(72);//g playKey(61);//a delay(2000);


playKey(138);//f playKey(105);//g playKey(61);//a playKey(61);//f playKey(61);//g playKey(72);//a playKey(94);//f playKey(116);//g delay(500); playKey(138);//f playKey(105);//g playKey(61);//a playKey(61);//f playKey(61);//g playKey(72);//a delay(500); playKey(138);//f playKey(105);//g playKey(61);//a playKey(61);//f playKey(61);//g playKey(72);//a playKey(28);//a delay(500); playKey(72);//a playKey(83);//a delay(500); playKey(94);//a playKey(116);//a playKey(105);//a delay(2000);

// somewhere over the rainbow

playKey(127); delay(300); playKey(50); delay(300); playKey(61);//f delay(300); playKey(83); playKey(72);//g playKey(61);//a playKey(50);//b delay(200); playKey(125);delay(300); playKey(72);delay(300); playKey(83); cli(); /*playKey(149);//g playKey(138);//a playKey(127);//b playKey(116);//c playKey(105);//d playKey(94);//e playKey(83);//f playKey(72);//g playKey(61);//a playKey(50);//b playKey(28);//c playKey(15);//d */




    • Epilog Challenge 9

      Epilog Challenge 9
    • Science of Cooking

      Science of Cooking
    • Pro Tips Challenge

      Pro Tips Challenge

    We have a be nice policy.
    Please be positive and constructive.




    what a wonderful project..applaud..This can be base for a much bigger one with humanoid sitting and playing piano.

    Thank you! Yes, that would be cool but beyond my ability.


    First, I apologize for my English is not good :)))

    this is a beautiful tool.

    I'm looking for a mechanical tool just like this for use in the sampling of the real piano.

    Basically I need a mechanic roobot I play all the notes of the piano, one by one, with different levels of intensity.

    This work is very tedious and time consuming to be done by one person, but a tool like this can help a lot.

    Please, you can have more information? perhaps there is a tool like this on the market.

    My e.mail:


    Hi Antonio. Unfortunately I don't have this or any other project anymore as I built them in China and have now come home to US.
    I have see a piano player built of legos that slowly progresses back and forth to play a tune. Anything more complicated than that would probably be quite complex. Do not know of any commercial product to play the piano and you are right it would be very time consuming to build. As you may notice, my projects are very simple - then when I get them working I make a video and forget about them pretty much.
    Good luck in your endeavors.

    Hi, I have made some changes to my player and found how to put videos in the comments section. So I am adding a video to show how this player works. This has been a fun project and have learned a lot from it. Thanks for all the help.

    Thank you, for taking the time to clean up the code. I now have a working machine. I need to get the finger alined with the keys on my keyboard but once I have that sorted out I think it will be playing many tunes. Will send video soon as I find out how.

    Thanks for the feed back.

    This one thing has me stuck. Can you tell me where you control the finger up and down timing. When the slider moves on my player the finger does not always clear the keys. Seems the slider moves before the finger has finished its stroke. I would think the finger should hit the key move up then the slider should move to the next key then the finger hit the key and so on.

    Sorry your job is not working out you seem to have a lot of talent.

    Ok, code is cleaned up and commented.

    But to reply to your question now: do finger down, then delay (to play key), then finger up, thendelay(to give time for finger up, then slide to next key, then delay(to give time to slide to next key),.

    I have a couple of questions,

    What does the line randomSeed(analogRead(0); do?

    How do you make the servo3 stay up long enough for servo1 to move to the next note? Seems to to have a problem with servo 1 staying on the key too long. I think the answer is in the void myServo but can't find it.

    How long are the rods from servo1 and servo 3 to the first bolt? I guessed servo1 to be 6.75" and servo 3 to be 3"

    I found the numbers in playKey that you have are different than mine.

    I almost have it working I think this is a fun project. I would send a video but don't know how to get it on youtube.