Who doesn't love music? These Piano Stairs are an interactive, relatively portable, musical installation that can be applied to basically any stairwell. I built them for HackPrinceton along with my friends Erica Portnoy and Vincent Castaneda, and we won 2nd place in the hardware track. I've had requests to share my code and diagrams, so I decided to make an Instructable!

These piano stairs use a light-based “tripwire” for each stair. The light sources should be on one side of the stair, the photoresistors on the other. In this setup, the Arduino reads from the sensors and passes the values to the Raspberry Pi, which generates the sounds.

What you need, assuming six stairs:
6 photoresistors
6 resistors, 1000 ohms each
6 light sources: I used flashlights, you can use bright LEDs
1 standard speaker set, w/ audio cable
1 breadboard
Soldering iron
1 Arduino Uno
1 Raspberry Pi

Step 1: Learn to Read a Light Sensor From the Arduino

You’ll want to follow Adafruit’s photocell tutorial for this.

I suggest that you first get your basic light sensor circuit set up, using a breadboard and an Arduino, so that you understand how the basic light sensing works. The image for this step is the basic diagram you'll need. Come back once you can read a photoresistor using your Arduino!

<p>very nice! awesome calibration algorithm. i made my version with breakout infrared sensors, worked perfectly. thank you.</p>
Very cool, thanks for commenting! I've been meaning to redo this with infrared sensors, definitely seems like a better long-term solution.
<p><iframe allowfullscreen="" frameborder="0" height="281" src="//www.youtube.com/embed/eCgsDmCPI5E" width="500"></iframe>Thanks for the tutorial! This was my first time using an Arduino and Raspberry Pi, and your instructable made for an awesome introduction.</p><p>Here's a picture of my breadboard and Arduino all wired up! (sorry if it's upside down)</p>
Hi! I am so glad you liked it -- and thank you for sending me the video + photo! It looks like it came out great. :)
<p>We did it!</p><p><iframe allowfullscreen="" frameborder="0" height="281" src="//www.youtube.com/embed/TAXnw2O3ifA" width="500"></iframe></p><p>This could probably be done without soldering using wire nuts for some solder joints. For example, instead of the long ground wire, you could probably do smaller pieces and wire nut them together at each stair step. I don't think you could do that with the photoresistor legs, but you could try just wrapping stripped wire around it and taping it with electrical tape or using small gauge heat shrink tubing. </p><p>Be sure you get all the python prerequisites in order, in terminal on your RPi do:</p><p>sudo apt-get install pygame</p><p>sudo apt-get install python-serial</p><p>Also make sure your configured to output audio the right way for your setup.</p>
<p>This is awesome! Thanks for posting this. Cute video!</p><p>And yeah, soldering probably isn't necessary -- it just made things simpler for my group. You could also just plug each photoresistor into a mini-breadboard hot glue stuff in place, if they give you trouble.</p>
<p>lovely project :)</p><p>I may add the piano effects to this other project: </p><p>https://www.instructables.com/id/Automatic-IoT-Staircase-Glowing-Lighting/#</p>
I mean, i need to know the details of the ldr :c
How many K has the ldr's?
<p>There's something wrong with the Raspberry Pi code that it does not work. PLEASE HELP ME CUZ I AM DOING THIS FOR MY PASSION PROJECT AND IT IS DUE IN TWO WEEKS!!!</p>
<p>I'm very new at this, but I'm fairly sure you need to place your code files in the &quot;home/pi&quot; directory(actually all files) &amp; then when you compile it, it will build the executable file for you &amp; place it in the same directory(home/pi) so when you give it the run command, it will go to that file &amp; run it until you give it the stop command(ctrl/c)</p>
<p>Hi!<br>This is a great project! I'm hoping to do this with my students verry soon. However, I'm having problems running the code in python. Do I have to save the github repo in a certain directory? For now I just unpacked the zip-file in &quot;Downloads&quot; on the Pi, but that isn't working very well. When I run the program there are a lot of &quot;FileNotFoundError&quot;. </p><p>Please help!</p>
<p>Hi, sorry. I'm just gonna leave another comment to ask if we can use light sensors instead as well :) Thanks!</p>
<p>Our company is manufacturing piano stairs (You may visit <a href="http://www.ThePianoStairs.com" rel="nofollow">http://www.ThePianoStairs.com</a> ). Light sensors will not work for a permenant installation. You should have industrial sensors.</p>
Hi. I'm new to raspberry pi. I don't know where I'm supposed to put the piano keys. All you tell me is to put the code. Where do I put the .wav files. I'm obviously new to pi bc everyone else gets it and I don't. :(
If I used an arduino mega...would I have to change too much of the code and gain more stairs? I can do a bit of coding but I'm no expert yet :)
<p>i wonder....if i have 30 stairs??? how can i do it?? using 2 arduinos?</p>
That's one option, or you can use a pin expander. More info here: http://electronics.stackexchange.com/questions/67004/how-do-i-extend-the-number-of-analog-input-pins-available-to-me<br><br>Full disclaimer, using a pin expander is a bit more complicated, and you'll need to alter the code to use it. But it's a cheap way to get extra pins.
If I have 10 stairs can I use the 6 analog pins and then the PWM pins? also how are the smaller ground wires connected to the large ground wire? Thank you in advance
<p>I think that this is a great project! I love that it uses a real piano sound and that it's polyphonic - I didn't expect that. Thanks for sharing this!</p>
<p>Thanks -- glad to hear that you liked it! </p>
<p>Would it be possible to use only an Arduino generating sounds through PWM?</p>
<p>Sure. Check out the Mozzi library. It just takes some more work (and knowledge of sound synthesis, to make it sound not-terrible).</p>
<p>when I run the py file on python, this window show that the port could not open.</p><p>Why it is happened, is it some wrong on the connection with the Arduino and Raspberry Pi?</p>
<p>One things I want to ask, May I plug 2 Arduino UNO board into the Raspberry Pi to make more stair, will it get problem when I do at this method?</p>
You will need to modify the Python code in order to do so, and you will need to handle receiving communication over two separate Serial ports. It's certainly doable, but will require some programming knowledge of your own.<br><br>Alternatively, you can look up how to take in more Analog inputs from an Arduino.
<p>Thanks for your opinion</p><p>Maybe I will try to use another Arduino board to get more analog inputs</p><p>And I may have some question about Raspberry <br>Pi later</p>
<p><iframe allowfullscreen="" frameborder="0" height="281" src="//www.youtube.com/embed/vMV_lfypvD4" width="500"></iframe></p><p><a href="http://blog.revealinghour.in/rhc/2015/01/31/piano-stairs/" rel="nofollow">http://blog.revealinghour.in/rhc/2015/01/31/piano-...</a></p>
<p>If I use LEDs are you sure that the light is bright enough?</p>
you also could replace the Raspberry pi with a wave shield for the arduino
<p>Actually you can't use a Wave Shield like this. Wave Shields are bound to only playing one sound at a time. In this video, you can hear the sounds of each piano key overlapping as they ring out.</p>
<p>hello, can explain better the design of the circuit?</p>
<p>Hey there! May I know if the other models of Arduino or Raspberry Pi would work with this setup? If there a restriction on which types we can use?</p><p>And can I see the full setup of wires? Because I know almost next to nothing when it comes to circuits :(</p>
How much would this cost
<p>I already had the arduino, rpi, breadboard and some flashlights. I had to buy some photoresistors at radio shack for $5, a 3 pack of cheap flashlights for $5 and some wire for $10.</p>
And could you do this without soldering
<p>Yeah, soldering isn't really necessary. You could chain together a bunch of alligator clips, for example, and that would probably work fine. wck86 has some good ideas too. I prefer to solder because it results in a more reliable connection. We actually cheated...some of the ground wire bits are wrapped together, not soldered, because we misjudged the lengths!</p>
<p>It can probably be done without soldering, see my comment on the page for details. The cost is very low if you have an arduino, flashlights and raspberry pi on hand, everything can be bought at radio shack pretty cheap. </p>
Would small wiener dogs be able to set off the notes as well, assuming they only need to break the light beam? Can't you just make this for me to buy? I'm never going to understand breadboards and Arduinos.
Small dogs would definitely be able to set off the notes! It would just depend on how wide the individual stairs are, and where you align the flashlights. But we had some dogs walk through that triggered them, actually. :)
I sense upcoming injuries
OMG! They have these at the Science Museum in MN, how awesome that you were able to make them! BRAVO!
Thanks! :)
that's too sweet!!! Now if I only owned a house....

About This Instructable




Bio: Software engineer at Twitter, based in NYC. Member of NYC Resistor. I do stuff with Arduino, musical programming, and lasers. See more of my projects ... More »
More by bonniee:Internet of Dirt: a Texting Plant Illumaphone: Light-based Musical Instrument with Arduino Caramelize Sugar onto Chocolate with a Laser Cutter 
Add instructable to: