Introduction: Music Editing, Sent to Buzzer and Gesture Control

About: A programer, maker, painter.        FB :       Linkedin:

Tired of playing single music in Arduino Buzzer?

Feel unhappy to edit the notes and beats in arduino source code?

Want to edit and update music easily by mobile app?

With RvPiano App, you can create your own music, recording / replay / save and send it to Arduino Buzzer via BlueTooth.

Step 1: Schematics and Arduino

Let's start from the Arduino part, then the App part.

As seen in the schematic, I use a Pro-mini, an UltaSonic, a button and a buzzer.

With ultrasonic, I can control the tempo of music, switch between default /uploaded song...etc by just waving my hand.

With button, I use it to switch between songs.

Before downloading the RvPiano main source code, you need to download my library, "danlib" first, and install it into Arduino IDE.

danlib :

then the RvPiano souce code.


There are 5 trigger events for ultrasonic gesture, you can easily use it without any further coding.

OnWave() // Hand Wave in/out
OnHolding() // Hand In and holding

OnHold() // Hand out after holding

OnNearToFar() // Hand out after holding from near to far

OnFarToNear() // Hand out after hloding from far to near.


With these gestures, you can easily integrate gesture control into your device.

Here is how I play a song with gesture of OnHolding().....


Once installed the danlib, you can new a template source from main menu, inside the danlib. Then you will see how the gesture works.


Also there are many trigger events for button, too.

OnButtonUp: OnButtonClick: OnButtonHolding: OnButtonHold: OnButtonLongHold:

Step 2: RvPiano App.

RvPiano App, a virtual piano let you create your own music and send music to Arduino buzzer via Bluetooth.

There are 3 versions, Win32, Win64 and Android.

You can create and upload music with Win32/Win64 version via UART in windows OS, or with Android app via Bluetooth.

There are 2 tabs in the app, Connection and Program.


Step 1 : Discover the arduino devices.

Step 2 : Select one in the listed devices.

Step 3 : Press "Connect" to connect the arduino device.

Program :

Step 1 : Press "Recording" button, then create/play music by pressing the piano keys.

Step 2 : Press "Recording" again to end recording.

Step 3 : Press "Replay" to listen your music. Press again to stop music.

Step 4 : Save music to *.mtf file, that you can reload it next time.

Step 5 : Press "Sending" to send music to Arduino device.

Here is the video :

Step 3: All Resource Downloads.

Step 4: How to Integrate Sonic Gesture Control


Step 1: Open a new sketch example, "UltraSonicGesture" from "danlib"


Step 2: Add source code as following in setup() and loop().


void setup() {

UltraSonicGesturer.Initial(cTrigPin, cEchoPin, &Process_WaveEvent);


void loop() {




Step 3: Add your control code in Process_WaveEvent()

// Triggered if WaveEven ---------------------------------
void Process_WaveEvent(TUltraSonicGesturer*, TWaveState ws, int aCnt, float frDistCM, float toDistCM) {

switch (ws) {

case wsWaveIn: // Hand in
// add your control code here......


case wsWaveOut: // Hand

// add your control code here......


case wsWave: // Hand in&Out

// add your control code here......


case wsHolding: // Hand in, holding

// add your control code here......


case wsHold: // Hand in , holding then out

// add your control code here......


case wsNearToFar: // Hand in, holding from near to far

// add your control code here......


case wsFarToNear: // Hand in, holding from far to near

// add your control code here......