Introduction: Arduino Plays Piano Tiles

Ever wondered if your phone can play games by itself. Yes, it is possible. You can build a circuit to play Piano tiles on your smartphone.

The video shows the demonstration of the project.

Step 1: Components Required

And the circuit can be built with simple components like Light sensors, Relays and Arduino.

Three main functions of the circuit are :
Sensing color of the tile (Black or White)Processing the color information and generating timing for the touch (Arduino)Simulating capacitive touch (Relays)

Step 2: Sensing

We use light dependent resistors (LDRs) to sense if the tiles are white or black. Four LDRs are positioned over the screen each facing one tile. The LDRs have been connected to the back of the cardboard like this.

The LDR resistance changes with the intensity of Light. Higher the intensity of light, lesser the resistance. LDR is placed in a Voltage divider circuit to produce a voltage proportional to its resistance.The LDRs are connected to the analog input pins of the Arduino as shown.

Practically, this is how you would connect the circuit. You can check the test_ldr code to see if the LDRs are working fine. When you run the code, you will get a high value from the LDR if it’s sensing black, else you get a low value.

Step 3: Processing

Arduino reads the voltage drop across the LDR. Observe the voltage voltages for Black and White tiles, choose a suitable threshold voltage say Vt. If (V

Step 4: Simulating Touch

For this we have to understand how capacitive touch screens work. The electrodes apply a low voltage to the conductive layer creating a uniform electrostatic field. When a finger hits the screen a tiny electrical charge is transferred to the finger to complete the circuit creating a voltage drop at that point on the screen. The location of this voltage drop is recorded by the controller and this is how a capacitive touch screen works.

We are going to use this concept, except that in the place of a finger, we use the ground pin on the arduino to transfer the charge on the screen. To have more surface area on the display of the screen, we use a coin.

Relays are directly connected to the output pin of the Arduino. It is equivalent to a touch if the voltage given is high as there is a path for the current to flow to the ground. It is equivalent to not touching if the voltage given is low.

Run the test_relay code at this link to see if the electronic touch is simulated properly.

Step 5: Finishing Touch

Once you the connect the circuit and dump the code main.ino at this link, your circuit should start working. If not, it is because the delays are not adjusted perfectly. Tweak the delay values in the code and it should work.

And you built a circuit that can play Piano Tiles better than any human in the world!!

Step 6: Other Resources

Comments

author
braytonlarson made it!(author)2015-07-22

Nice. Replace the relay with an NPN transistor though and you will have a much cheaper and smaller project.

author
psurya1994 made it!(author)2015-07-23

Agreed, thanks for pointing out. :)

author
ssarwar made it!(author)2016-02-08

hy...is it possible to replace relays with npn transistors???? spent all my money buying an arduino :( relay are not so cheap

author
Sanderv2 made it!(author)2015-07-25

Couldn't this also be done directly from an Arduino pin? Giving low (ground the pin) for a touch and high for no touch.

author
braytonlarson made it!(author)2015-07-30

I suppose that would work as well. Would have to add a resistor to the ground line of the arduino. Good thinking!

author
psurya1994 made it!(author)2015-07-30

The idea won't work.

author
psurya1994 made it!(author)2015-07-30

Nope. Never do that. You need to switch between open circuits and ground (not Vcc and ground)

author
Tanmay+Deuskar made it!(author)2017-04-10

Hello,

I've been trying to get the coin thing working, but it simply doesn't simulate the touch. Can you tell me what could possibly be going wrong or how I can troubleshoot it. I want to simulate touch using Arduino to take photos.

Thanks

author
SouvikC6 made it!(author)2017-03-27

can you plz tell me how coins are used here to touch the screen??

author
theglenneth made it!(author)2016-08-07

Hey, I was wondering if you could be more detailed about how you got the screen to think it is being tapped. When i put the contact i made on the screen, it registers a tap, but when i apply 5v or 3v, it does not register as it no longer being touched. Am I hooking it up wrong?

author
Shivama22 made it!(author)2016-06-13

Can u share the circuit diagram u have designed?

author
Aswinm1 made it!(author)2016-05-22

Which relay did you use .I really want to make this.EAGERLY waiting for your replay.Also a very nice project

author
JakubZ9 made it!(author)2016-03-11

What should be the parameters of LDR's ?

author
Hertafeld made it!(author)2016-03-10

Great project! I'm trying to do something similar using relays on a phone screen (without the arduino). I'm using tin foil contacts instead of coins due to space constraints. With one side of the relay grounded and the other making contact with the screen, activating the relay DOES register a touch. The problem I'm facing is that when the relay is switched off and the contact is floating, the phone does not register a "release" and remains "touched" until the contact is physically removed. Did you come across this issue, and how did you solve it?

author
asilva57 made it!(author)2015-08-28

Great idea guy! GO ahead with the project e thanks for sharing.

author
psurya1994 made it!(author)2015-07-30

Try a different coin.

author
Akshayraman777 made it!(author)2015-07-23

I love it

author
psurya1994 made it!(author)2015-07-30

:D

author
coolkids made it!(author)2015-07-26

finally something that will ensure complete victory in this game hahaha

author
psurya1994 made it!(author)2015-07-30

Haha :)

author
psurya1994 made it!(author)2015-07-30

Haha :)

author
Everything+impossible made it!(author)2015-07-26

Amazing

author
psurya1994 made it!(author)2015-07-30

Thanks!

author
psurya1994 made it!(author)2015-07-30

Thanks!

author
countywide-environmental made it!(author)2015-07-23

Love it

author
psurya1994 made it!(author)2015-07-23

Glad to hear that :)

author
tomatoskins made it!(author)2015-07-22

This is just awesome! Thanks for sharing and welcome to the community!

author
psurya1994 made it!(author)2015-07-22

I'm glad you like it. Thanks. :)

About This Instructable

20,071views

158favorites

License:

More by psurya1994:Breaking World Record High Score in Paper TossArduino Plays Stick HeroArduino Plays Piano Tiles
Add instructable to: