Robotic Piano Player

10K7628

Intro: 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() {

Serial.begin(9600);

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

servo1.attach(9);

delay(10);

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

servo3.attach(11);

delay(10);

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() {

digitalWrite(ledPin,HIGH);

/* 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);

//gilligan

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 */

}

26 Comments

Wonderful project! Would love to give it a try with some of the school districts I'm working with :) Is this all of the code or is there an additional header file to be included? Can't figure out how the "playKey" parameters are defined.
Sorry I never saw your question. Hope you got it figured out.
Can we do this project using Arduino mega 2560
Wow, never answered this. The answer is yes. Hope you made one.

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.

Hello,

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: antonioserio64@alice.it

Thanks!
Sincerely
Antonio

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.

you dont need randomseed function in this program. code was carried over from my robotic newton's cradle. sorry.

Question 1: see http://www.arduino.cc/en/Reference/RandomSeed
description for randomseed "seeding"
Question 2: Servo 3 is the slider and servo 1 is the finger up and down.
Question 3: Long rod 7". Short rod from servo to long rod: 3"
Finger from servo to 2nd finger joint: 2 1/4"
Numbers are arbitrary depending on which note you start on. Also my keyboard has the black notes mixed in with the white ones so your keyboard is correct.
Glad you built one. Rock on!
I am winding down on projects. Probably have one more then I hve to move on and get a real job, not the flakey one I have now, Will miss all this putzing around.

I have a problem with code....can you help me ?

sketch_may13a:1: error: #include expects "FILENAME" or <FILENAME>

sketch_may13a:2: error: 'Servo' does not name a type

sketch_may13a.ino: In function 'void myServo(int, int, int, int, int)':

sketch_may13a:6: error: 'servo1' was not declared in this scope

sketch_may13a:6: error: 'servo2' was not declared in this scope

sketch_may13a:6: error: 'servo3' was not declared in this scope

sketch_may13a:6: error: 'servo1' was not declared in this scope

sketch_may13a:6: error: 'servo2' was not declared in this scope

sketch_may13a:6: error: 'servo3' was not declared in this scope

sketch_may13a.ino: In function 'void setup()':

sketch_may13a:8: error: 'ledPin' was not declared in this scope

sketch_may13a:10: error: 'servo3' was not declared in this scope

sketch_may13a.ino: In function 'void playKey(int)':

sketch_may13a:10: error: 'servo3' was not declared in this scope

sketch_may13a:10: error: 'servo1' was not declared in this scope

sketch_may13a.ino: In function 'void loop()':

sketch_may13a:12: error: expected '}' at end of input

#include expects "FILENAME" or <FILENAME>

#include <servo.h>

I was so impressed with your player that I made one of my own. I was very impressed with the way it works and how well it plays. It looked like it would be easy to make but it did not turn out that way. Have much more to do on mine.

Looks great! Would like to see video of yours. I plan to use printer carriage parts in a future project.
More Comments