keyestudio
Share your creative ideas with us here
By keyes | 16 November 2018 | 0 Comments

How to Make Bananas Become Your Piano Keys

 
Instead of using the computer keyboard keys, it is an interesting thing for you to make bananas become your piano keys combined with keyestudio maker touch shield.

 
 
Introduction:

Maker Touch is a very simple circuit board, and can make any objects become a computer input device when used with open-source ARDUINO control board.

This shield has small volume, a USB interface connected to computer and a alligator clip connected to other objects. 

You can use it combined with Arduino, and compile corresponding codes into Arduino to make Maker Touch replace different keys of keyboard. 




To make your daily life fill with joys, let's play this interesting project. Followed by below steps.


Preparation:


 
Work Principle:

It uses ARDUINO microcontroller to simulate a keyboard, and leads out several keys to replace switches as touch switch.

Maker Touch employs touch input, namely, a double-contact switch, and leads out both touch port and ground to connect to two touch electrodes.

When you touch the two electrodes, there is certain current flowing through between them because of body-resistor. Detect the current to know touch events. 



Schematics



Step1: Wiring

First, plug Touchkey USB Shield into Uno board. Then, connect one end of single alligator clip to GND; connect one end of other alligator clips to A0-A5 port, the other ends are connected to bananas.






Step2: Program and Upload the Code

Open Arduino IDE, compile and upload the code to the board.
Download the code libraries here:

https://drive.google.com/open?id=1CwJBxoXhGQPivVE-_Be9_L39lLGwRwDV

please check out the following code:
 
#include "UsbKeyboard.h"
int InData1 = 0, InData2 = 0, InData3 = 0, InData4 = 0, InData5 = 0, InData0 = 0; //touch input value
//temporary storage
int TouchSensitivity = 50; //touch sensitivity. 0~1023the larger the value, the lower the sensitivity.
void setup()
{
for(int i = A0; i <= A5; i++)
{
pinMode(i, INPUT); //A0~A5 port as input port
}
for(int i = 6; i <= 12; i++)
{
pinMode(i, OUTPUT); //A0~A5 port as input port
}
TIMSK0 &= !(1 << TOIE0);
}
void loop()
{
UsbKeyboard.update();
//read out the voltage value of all pins, and because of pull-up resistor
//the default of all pins of maximum level is 1023decrease the level of pins though touch.
//so the value is by 1024-analogRead(A0);
InData0 = 1024 - analogRead(A0);
InData1 = 1024 - analogRead(A1);
InData2 = 1024 - analogRead(A2);
InData3 = 1024 - analogRead(A3);
InData4 = 1024 - analogRead(A4);
InData5 = 1024 - analogRead(A5);
//trigger keyboard events with various possibility
if(InData0 >= TouchSensitivity)
{
digitalWrite (11, HIGH);
UsbKeyboard.sendKeyStroke(13); //J
delay(50000) ;
}
else digitalWrite(11, LOW);
if(InData1 >= TouchSensitivity)
{
digitalWrite(10, HIGH);
UsbKeyboard.sendKeyStroke(14); //K
delay(50000) ;
}
else digitalWrite(10, LOW);
if(InData2 >= TouchSensitivity)
{
digitalWrite(9, HIGH);
UsbKeyboard.sendKeyStroke(15); //L
delay(50000) ;
}
else digitalWrite(9, LOW);
if(InData3 >= TouchSensitivity)
{
digitalWrite(8, HIGH);
UsbKeyboard.sendKeyStroke(12); //I
delay(50000) ;
}
else digitalWrite(8, LOW);
if(InData4 >= TouchSensitivity)
{
digitalWrite(7, HIGH);
UsbKeyboard.sendKeyStroke(11);//H
delay(50000) ;
}
else digitalWrite(7, LOW);
if(InData5 >= TouchSensitivity)
{
digitalWrite(6, HIGH);
UsbKeyboard.sendKeyStroke(8);//E
delay(50000) ;
}
else digitalWrite(6, LOW);
delay(100);
}



Step3: Play Your Piano With Bananas

After uploading program, take down one end of USB cable from Uno board; then plug it into Touch key USB Shield, and the other end still into PC USB port.

Hold the metal part of the other end of the alligator clip with a finger of your one hand; the other hand touches bananas which have been connected to A1-A5 port.

Then, open a blank document. You can see that one banana represents one key when touching the bananas, including 6 keys J, K, L, I, H, E.



Next, open online piano software. You can click here to download.

Finally, enjoy playing the Song of Joy
J J K L L K J I H H I J J I IJ J K L L K J I H H I J I H H I I
J H I J K J H I J K J I H I E J J K L L K J I H H I J I H H
 

Check the video here:
 
Enjoy your time!  Or you can also use the maker touch shield to do other games, like tank game with coins.  Feel free to click here for more detailed info.


 

Leave a Reply

Your email address will not be published.Required fields are marked. *
Name
E-mail
Content
Verification code
TAGS