Piano Staircase





Introduction: Piano Staircase

About: I love to learn,build and design.....

As you guys know April 1st was celebrated as " ARDUINO DAY" and it was a celebrated in our college by conducting various events and workshops.It was a very special day for me....

Since i was very interested in Arduino,I was given an opportunity so that students should be attracted,involve and have fun......I really thank all the people who supported and believed in me....

Here i will be explaining about methods i have applied in making this fun filled project....

what will be discussed here...

1) Research on components (Here there will be alternatives for the components)

2) Electronics...connections...

3) Arduino code

4) Processing code

Step 1: Things Used for This Fun Project

• Arduino UNO
• Processing 3 software
• 6 X Ultrasonic sensors-----(6)
• External speakers------(desktop speakers optional)
• Jumper wires
• Breadboard------(initial testing)

Let's get started.....

Extra parts which will be using for final prototype...

• Screw terminals
• Wires really long it depends on length of the stairs

Step 2: What Is Piano Stairs?

Piano staircase is basically and interactive interface which sounds with different tones when you step on stairs one by one...

Piano staircase is basically an application that plays specific audio files when sensor is triggered.

According to my analysis, the act of stepping on steps can be transferred to micro-controller using sensors...

1) Using LDR for each staircase but the disadvantage is there will be huge amount of work to calibrate and not preferred stairs exposed to sunlight.

If you guys are interested in doing this project using LDR here is the link of Instructable

2) Using contact type on each stair like switch with completes the circuit and gives a signal to micro-controller

3) Using IR sensors(low cost) it has very short range and cannot be calibrated according to distance and it interacts differently with different colors.

So this made me ended up using 'ULTRASONIC SENSOR' which simply detects any obstacle in front of it using time required to receive the sent ultrasonic pulses...

Step 3: Implementation and Working (Using One Ultrasonic Sensor)

These piano stairs use a Ultrasonic sensor for each stair. There should be flat surface on one side of the stair, the ultrasonic sensor on the other. In this setup, the Arduino reads from the sensors and passes the values to the processing software serially which plays the sounds from the audio files attached to the processing code.

  1. Connect the sensors to Arduino as shown in above image.
  2. Make sure that if you are using digital pins ultrasonic uses trigger pin for transmitting ultrasonic waves and echo pin to receive (PWM pin of Arduino)
  3. Data received is passed through usb cable connected to Arduino uno and computer

***Since I am contesting on INVENTION please show your support by Voting***

Step 4: Arduino Code and Processing Code for One Sensor

If you are new to Arduino download the Arduino compiler i.e ide from the link here---Arduino IDE

And processing ide can be downloaded from here---Processing IDE

Here is the arduino code for one sensor only for initial understanding of program


(Make sure that header file is in same folder)


(Make sure that all the files provided here should be in one folder)

Once we have uploaded the code to Arduino UNO, we will be able to see a data in the serial monitor.(Exit from the serial monitor while using processing)

First, download Processing IDE from Processing official website.as i have given the link above and then install the contributed library “Minim” in Processing IDE.

After that, reboot your computer just to make sure the library is detected by Processing....

I have provided some of the piano notes you can change them as you like...

That's it turn up the volume.....

I choose processing because, since output of microcontroller is in digital it should be converted to analog to sound like(to power speaker) piano and we will be needing musical shield and this costs more instead we can use soundcard of computer and make it hear more natural...

***Since I am contesting on INVENTION CONTEST please show your support by Voting***

Step 5: Now Its Time for 6-sensors

  • If you are planning to add more sensors use analog pins for echo pins input to arduino


(Make sure that header file is in same folder)


(Make sure that all the files provided here should be in one folder)

Once we have uploaded the code to Arduino UNO, we will be able to see a data in the serial monitor.

it should look something like this 223,234,245,233,220,277

You can see there is lots of lag this can be reduced as i kept boxes is to reduce the range this is because it reduces the time required for reception of ultrasonic waves....

And this may look 93,97,95,94,99,93,98

The threshold for detection of obstacle or till where the sensor should detect can be changed using the line which i highlightined in processing image.

In case peeps you find an error in any sort of time just leave a comment i will definetly go through it...

Step 6: Wire Up Everything

Firstly take the measurements of the steps.This is really important since we should not be wasting wires or run short

As shown in above image distance between the steps was 45cm and since we are placing sensors in between the stairs the length between each sensors will be 45cm(approx)

Calculations for wires:(according to image)(from the arduino uno)

45cm =1.5feet

(For 6th sensor)6 stairs X1.5 feet=9feet wires required

(5th sensor) 5th stairX 1.5feet=7.5feet

(4th sensor)4 stairX1.5 feet=6feet

(3rd sensor)3 stairX1.5 feet=4.5 feet

(2nd sensor)2 stairX1.5 feet=3 feet

(1st sensor)1 sensorX1.5 feet=1.5feet

Each sensor has trig pin and echo pin which should connected to arduino uno so all the calculation above should be multiplied by X2.

And VCC and ground is connected in parallel.

I soldered all the wires to the sensor and connected to screw terminals other side of terminal was jumpers which will be easy to connect to arduino uno.(Image is provided)

Setup sensors on the one side of wall (i used double sided tape) and tape up the running wires,and like i have said to prevent lagging i used boxes.

Make your own piano stairs for college fests, or as fun project at your home...


***Since I am contesting on INVENTION CONTEST please show your support by Voting***

***Also share it with your friends***

See you at my next instructable !
Thank you

Adithya Pai P



    • Planter Challenge

      Planter Challenge
    • Woodworking Contest

      Woodworking Contest
    • Make it Move Contest

      Make it Move Contest

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


    2 Questions

    Are those functions used in arduino code and processing ide connecting and the music files are in same folder....

    I tried to verify the code and it highlighted the line "import ddf.minim.*;" and at the bottom it says 'import' does not name a type

    1 more answer

    Which files/folders would that be specifically?

    Hello. My school is trying to make these for a set of stairs. We are having issues with the coding. Could you possibly provide a more in-depth tutorial on the coding portion? Thanks!

    Im not exactly sure what it is. We've followed the tutorial but we are having issues getting the Arduino IDE and the Processing IDE to "talk" to each other. Any tips?

    1 more answer

    I am little bit busy to make a different tutorial on it.....If you have any doubt in specific line in code let me know here....


    Thanks very much, how can we add more sensors. for example 20 or 30 sensors, is it possible?

    10 replies

    You can use analog pins also which are remaining but if you need to connect more I suggest arduino MEGA which has more pins...

    Hi, I tried to use MEGA 2560, AS I am using Music Shield I can just use pins number 14 to 53 I changed the values in sensor class to pin number but it always returns 0, is there anything which I am doing wrong?when I connect sensor to pin 9 and 10 it works fine

    I am little bit busy to make a different tutorial on it.....If you have any doubt in specific line in code let me know here......

    thanks, in fact I have another problem, in this tutorial you have used your pc to play sounds. what if we want to play it directly using Ardinu and use an external amplifier? is it possible?

    I think its cost effective and it should work....

    Thanks very much, the problem will appear when I want to add more stairs and also this shield, it seems I must switch to Mega, also I noticed about this hint:Note : Limited by the transmission speed and memory shortage, Arduino boards like UNO and Leonardo can neither play WAV files, nor use the recording function. NUCLEO or Due are recommended. does it make any problems while playing?

    thanks very much

    Can you provide a more in-depth tutorial on the coding portion?

    How do you go from the initial testing for the 6 sensor to having them mounted on the wall ? I cant seem to get it to work and I dont quite understand the photos

    1 reply

    Connect as per the fitzing diagram each module has common vcc and ground connection is connected to arduino then each modules trigger and echo pin connection is connected to different pins of arduino....

    Hi. Thanks for the awesome project. Having a bit of trouble though: getting major sound delay even with barriers. Any ideas?

    1 reply

    delay will be due to the delay required to run the music file and processing application eats up ram even i got some delay initially(Point to remembered barriers should not be far and should not be removed or else there will be huge lag or error full measurements)Hope this solved your problem.

    hi your project is very good . i am working on automatic stair case lights. (using 2 pir sensors one is up and one is down + arduino uno + relays to on lights). but facing problem is that one pir sensor detects and send signal to arduino to run relays in sequence and when a person travels from down stairs to up stairs the up pir sensor also detecting and reserving the process and after the down pir process completes then it starts the process automatically .. so how to hold a pir sensor not to detect if any one detected in both and in process ...

    1 reply

    Pir sensors works as trans receivers so.. I will tell you what I have understood from your query... Staircase lighting circuit is required which automatically turns off while person reaches top of the stair but your question is what if person from top of the stair walks down at the same time.....
    Solution: Install another pir between the staircase (halfway) and control all the pirs relays using one arduino program it by checking && logic and || logic with pir installed in halfway....with top pir or down pir....sequential if loop....
    If you have any doubts you can ask again....
    All the best...

    What is the cost of ultrasonic sensor and how much did it cost you to make it....

    1 reply

    Each ultrasonic costed me around 50 Rupees i.e 0.78$, And total with arduino ended up within -(600Rupees) 10$