Ultrasonic Air Drums

by taste_the_code in Living > Music

2192 Views, 20 Favorites, 0 Comments

Ultrasonic Air Drums

MVI_0812.MP4.00_00_20_13.Still001.jpg
How to make an ultrasonic non-contact Arduino Air Drum Set for hours of fun

I've always been a fan of air instruments where you make music without touching anything so when DFRobot offered to send some sensors so I can make a project with them, I pitched the idea of making a set of Air Drums.

An Air Drum is a device where you can make a rhythm without actually hitting any surface and for that, I'm using ultrasonic sensors that detect when my hands get close enough to the sensor.

Supplies

MVI_0736.MP4.00_00_20_18.Still001.jpg
MVI_0738.MP4.00_00_05_23.Still001.jpg
MVI_0738.MP4.00_00_23_00.Still002.jpg

The project is based on the URM09 sensors from DFRobot as well as their FireBeetle ESP32 development board that has WiFi, Bluetooth, and an onboard lithium charging circuit so the entire drum kit can be made portable.

You can check out the DFRobot store here: https://www.dfrobot.com/

Below is a list of all the DFRobot sensors and controllers used in the video:

Solder Headers to the Microcontroller and Expansion Shield

MVI_0739.MP4.00_01_46_12.Still001.jpg
MVI_0740.MP4.00_00_14_28.Still001.jpg

To start working with the sensors and the expansion shield for the FirBeetle Microcontroller, we first need to solder headers to them so the two can be connected together.

This is fairly easy and all the required headers are provided with the boards.

Test Out the Communication With FireBeetle Microcontroller

MVI_0742.MP4.00_00_56_00.Still001.jpg
MVI_0742.MP4.00_01_12_26.Still002.jpg

To add the FireBeetle board to the Arduino IDE we can follow the instructions on the official wiki for it. As with other boards, we first need to add the board definition to Arduino IDE and after that, the board will become available in the selection dropdown.

The URL to add is:

http://download.dfrobot.top/FireBeetle/package_esp32_index.json


To verify that we can program it, I like to always start by uploading the basic blink sketch and making sure that the upload process goes as expected.

Read the Distance From a Single URM09 Sensor

MVI_0823.MP4.00_00_09_29.Still001.jpg
MVI_0823.MP4.00_00_21_29.Still002.jpg
MVI_0824.MP4.00_00_33_00.Still001.jpg
MVI_0743.MP4.00_01_52_28.Still001.jpg
2023-01-16 08-43-27.mp4.00_05_10_29.Still001.jpg
2023-01-16 08-38-32.mp4.00_02_53_25.Still001.jpg

The drumming will be detected by 4 ultrasonic distance sensors URM09. The sensor can read distances of up to 50cm so anytime our hand comes closer than 10, we will play a different drum sound based on what sensor was triggered.

To read the distance of the sensor, DFRobot has a dedicated library, and all the details can be found on the product wiki page.

After installing the library, I used the provided example sketch to read the sensor and successfully detected the distance of my hand from the sensor.

Read the Distance From Multiple Sensors

2023-01-17 07-29-29.mp4.00_01_16_29.Still001.jpg
MVI_0745.MP4.00_00_01_25.Still001.jpg
MVI_0746.MP4.00_00_07_27.Still001.jpg
MVI_0746.MP4.00_01_23_15.Still002.jpg
MVI_0747.MP4.00_01_27_19.Still001.jpg
MVI_0747.MP4.00_02_44_03.Still002.jpg
2023-01-17 07-52-30.mp4.00_02_40_28.Still001.jpg

Now that we have one of the sensors working, we need to expand it so there can be multiple ultrasonic sensors. In my case, I will be using 4 but they can be even more.

Since all of the URM09 sensors come preset at address 0x11 for the I2C communication, we need to change this address to three of them so there are no collisions.

For that, there is a sketch provided that we need to upload to the microcontroller and we can change the addresses to 0x12, 0x13, and 0x14 for the rest of the sensors.

Once the addresses are changed, we can then use the I2C hub from DFRobot to connect all of the sensors to it and then connect the hub to the FireBeetle board.

To measure the distance from all of the sensors, I just replicated the code from the example sketch to have 4 instances and 4 printouts and everything worked as expected.

Fail: Try to Play Drum Sounds With MP3 Player

MVI_0748.MP4.00_00_08_12.Still001.jpg
MVI_0810.MP4.00_01_24_15.Still001.jpg
MVI_0810.MP4.00_01_58_23.Still002.jpg
MVI_0811.MP4.00_00_15_06.Still001.jpg

My initial idea for the project was to make it a standalone thing where all of the drum sounds will be played through an MP3 player and a speaker but since the player can only play one file at a time, I quickly realized that this will not work, at least not in the way that I had imagined that it will.

Anyway, for the player, I used the DFPlayer Pro module, again from DFRobot and I connected it to be controlled via UART from the FireBeetle board.

The player module has 128MB of onboard storage so when I connected it to my computer, I was able to copy sounds to it that were then played based on what sensor was triggered.

This all worked nicely, but as I mentioned before, I wasn't able to get the desired effect because when I tried to make more elaborate beats, the previously playing sound would be cut off once a new hit was detected and that is not how real drums work.

Having a dedicated player for each sound would have solved this but instead, I declared this step as failed and moved to use MIDI instead where the sound will be generated on a computer.

Add BLEMIDI Functionality

2023-02-20 11-28-52.mp4.00_02_17_25.Still001.jpg

I'm no MIDI expert but using the provided examples from the Arduino MIDI as well as the BLE-MIDI libraries, I was quickly able to create a sketch where instead of playing a file when a hit is detected, I was sending MIDI notes to the receiver.

The receiver can be any Bluetooth-enabled device like a computer or a phone so the entire controller can be easily used for other music generation as well.

One of the items that I struggled with the most was to have my device recognized as a BLE MIDI device and for that, I had to install a special driver from Korg that I found here.

Connect to MIDI Enabled Software on PC

2023-02-18 08-36-02.mp4.00_00_15_22.Still001.jpg

Any MIDI software can be used but for my example, I opted to use FL Studio. This is paid software but it has a long enough trial so that I can make the example work and properly test it.

As I said before, I'm completely new to MIDI so if you have any recommendations on other, possibly free applications that can be used, please leave a comment below.

Start Drumming

MVI_0825.MP4.00_00_24_08.Still001.jpg

Now with everything connected, it was time to start drumming and I must say that I had a great time playing the drums with my kids.

Not that we knew how to drum but producing a sound by just waving your hand was fascinating and really enjoyable so I call this project a win.

All of the code can be found on the project repo at: https://github.com/bkolicoski/arduino-air-drums

If you liked it, then you can also check out my other Instructables and my YouTube channel for more projects and tutorials.


Thumbnail photo by Tunahan Günkan on Unsplash

https://unsplash.com/@tunahangunkan

https://unsplash.com/photos/KjlYuYFIayo