Introduction
Wireless music instruments are reshaping how we interact with sound, bringing portable and interactive creativity right to our fingertips! Learn what a digital piano is, how wireless Bluetooth data transmission works, how to interface an ESP32 board with your smartphone, and program it with ease in PictoBlox – our Scratch blocks-based graphical programming platform with advanced hardware interaction abilities. Once you’re equipped with the basic knowledge of the Dabble app’s Music module, Bluetooth pairing, and digital triggers, we’ll show you how to build a fully functional wireless touch-piano and other exciting DIY smart music projects using your ESP32 and smartphone.
To work in PictoBlox, you’ll first need to download it from HERE.
Ready? Set. Go!
Prerequisites
- ESP32 Board
- Laptop or Computer
- PictoBlox installed on the system
- Smartphone
How to connect with ESP32
- First, open PictoBlox.
- Click on the Board tab on the toolbar and select ESP32.

- Next, click on the Connect button and select the appropriate serial port.
- In the top right corner, there is a toggle button named Mode. This button is used to switch between the two working modes of PictoBlox, namely the stage mode and the upload mode.
- Switch to Upload mode by toggling this button. You’ll observe some changes in the UI.
Step-by-Step Block Coding Guide
- Go to the ESP32 palette and drag the ‘when ESP32 starts up’ block into the scripting area.
- From the ESP32 palette, add the ‘set Bluetooth name to ()‘ block. Set its value to ‘MyEsp32‘.

- From the Control palette, add the ‘forever‘ block.
- Inside the forever block, add the ‘if () then else‘ block from the Control palette.
- Inside the if condition, add the ‘read status of digital pin ()‘ block from ESP32 palette. Set its value to ‘26‘.
- Inside the if block, add the ‘wait () seconds‘ block from the Control palette. Set its value to 0.3.
- Underneath the ‘wait () seconds‘ block, add the ‘() music file ()‘ block from ESP32 palette. Use the ‘play’ function and set the music file as ‘C4‘.

- Inside else, insert ‘if () then‘ block from the Control palette.
- Inside the if condition, add the ‘read status of digital pin ()‘ block from ESP32 palette. Set its value to ‘27‘.
- Inside the if block, add the ‘wait () seconds‘ block from the Control palette. Set its value to 0.3.
- Underneath the ‘wait () seconds‘ block, add the ‘() music file ()‘ block from ESP32 palette. Use the ‘play’ function and set the music file as ‘D4‘.

- To upload the code, click on the Upload Code button.
Pairing Dabble with ESP32
- Install the Dabble app from Play Store and open it on your smartphone.
- Next, click on the connect-disconnect icon.
- A dialogue box will appear on the screen asking for permission to turn on Bluetooth. Click on ‘Allow’.

- Once you do so, a list of nearby devices will appear. Select your device’s name.You will find ‘MyEsp32‘ as the device to connect.
- In case you don’t see it on the list, go to the Bluetooth settings of your Smartphone and search for it there.
- A notification will appear in the drop-down menu of the phone once the connection is made.
- Once connected successfully, open the Music Module.
- Touch the Digital PWM Pins D26 and D27 on the ESP32 and watch how the tones start playing.
Output
Conclusion
In this lesson, we explored how to create a custom wireless Bluetooth Piano by interfacing the ESP32 board with the Dabble smartphone application. We learned how to initialize a secure, real-time wireless connection using the ESP32’s onboard Bluetooth without requiring any external communication modules. By utilizing the Music module inside the Dabble extension, we successfully mapped incoming data packet triggers to specific musical keys and audio frequencies




