Another game has been going viral recently – Piano Tiles.
I tried playing it, and it sure is entertaining, but there’s no way I can beat some of my friends, they’re just too good (Sunny, I’m looking at you 🙂 ). Not willing to throw in a towel that easily, I employed robots to do the dirty job. Results can be found below.
I used an Arduino Uno with a relay shield (makes for more compact package than having relays on breadboard), photoresistors to read the color (~light intensity) of the tile (black vs white), and strips of copper foil attached to the screen to simulate touch by grounding them. Algorithm is monitoring the timing between tiles, to account for increasing speed at which tiles move as the game progresses.
Reliably simulating touch was the toughest part – I tried a number of different approaches (pennies, washers and more), but 3-4 layers of copper tape seemed to work best. Just make sure that the glue on copper tape is also conductive (I used this one) and that you share the ground with phone (i.e. by connecting a stripped USB cable to the phone and getting the ground from there).
YouTube video – compilation:
YouTube video – raw footage:
6 thoughts on “Piano Tiles – Arduino Hack”
Hi! I’m trying to build this click/touch mechanism of yours for another game (taps to riches) and I’m failing hard 🙁 the code is pretty simple and the relay shield clicks nicely. but there are no touches registered on the phone and I don’t know why 🙁 also, I don’t understand what you mean by sharing the ground… Can you help me and tell me how to wire it?
I have this relay board (https://www.amazon.de/Neuftech-Kan%C3%A4le-Relais-Modul-Brett-Arduino-2/dp/B00PIMRGN4) and a nodemcu
The relays are fine, this board should work perfectly.
I’m assuming you’re also using copper tape as “touch point”? Just double-check that the glue is also conductive, i.e. check continuity with multi-meter, to avoid surprises 😉
Now, the touch-points need to be connected to ground (through relays). And by “shared ground” I meant that there is a connection between the ground of your microcontroller (its power supply) and the ground of the device you’re trying to simulate touch on (i.e. phone).
To achieve that, grab one of the USB cables used to charge the phone, then cut it, strip piece of insulation to expose the wires, and check which one is ground (to find that out, check the USB plug pinout for the type of cable you have for your device, and then simply check continuity from that pin to the wires that you removed insulation from, i.e. for USB Micro-B: http://www.hobbytronics.co.uk/usb-connector-pinout). Separate and insulate unused wires for safety.
Make sure only ground is shared, DON’T connect the Vcc lines of your microcontroller and the device (you can damage both devices)!
And quick and easy way to verify if the problem with touch is because of no shared ground: plug in both the devices to power outlets in your home (i.e. power microcontroller from wall outlet and plug in your phone to charger too) – as this way the ground becomes shared (in the wall… 🙂 ).
Hope that helps! Let me know if you have any additional questions.
Great project! I’m trying to do something similar using relays on a phone screen (without the arduino). I’m using coin contacts instead of Copper foil. 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?
Hi Kaan! Unfortunately I don’t remember encountering that problem… However, considering the differences between our circuits (copper tape vs coin), maybe swapping it (just be sure to use one with conductive glue) could yield some interesting results? 😉 Hope you get it sorted out, please share your findings back, I’d love to learn what was the culprit.
Hi, what pin is the ground wire coming from the phone port going into?
Hi Graham, the ground from USB cable is split into each relay, and connected to the COM (common) pin on each one of them.
With the other wire from the conductive tape stuck onto the phone’s screen connected to NO (normally open) pin on the relays, when we close a relay, we connect that “simulated touch point” to ground, thus simulating a touch.
Looking at the wiring I did after the years, I’d now just route single ground wire from the USB cable from the phone to the breadboard and split it from there, but either approach works 😉