Introduction
The Music module allows you to play tones, songs and other recorded audio files from your phone’s storage as per command send from the hardware device. You can send the command to play or stop an audio file. You can also give commands to play various audio files one by one in a queue.
Follow the steps below to play different audio files from this module:
- As you open the music module you can see three tiles on the screen. Two tiles are named A4 and B4 and one tile has ‘+’ mark on it. On clicking A4 or B4 tile, some music will be played. Here A4 and B4 are keys associated with those music files. You can add your own key tile by clicking on the tile marked ‘+’. This tile is an added tile.
- To add audio files of your own choice click on Add tile. You can see a screen as shown below. There you can see a message above the text box “Enter a key and select audio files” informing you to enter the key name and then select a music file.
- You can select audio file either from the list provided below or from your phone storage. To select an audio file from phone storage scroll at the bottom of the list and select “Tap here to see music from device”.
- You will be asked for permission to access media files. Select “Allow” and proceed.
- You would see two different sections named “Default” and “Device” containing various music files.
- Enter a key name say “D2” and select an audio file. As soon as you do this a new tile named “D2” is created and when you click on that tile your selected audio file will be played.
- You can also delete any music tile by doing a long press on that tile.
- In order to play these files from your hardware, you have to send these key names from your hardware. How to do this? It will be more clear from the explanations and examples as given below.
Arduino IDE Functions
Header
To include the GamePad module in the Arduino program, you have to include the following header:
#define CUSTOM_SETTINGS
#define INCLUDE_MUSIC_MODULE
After defining the above mention headers, you have to include the dabble library:
#include <Dabble.h>
You can download the zip of Arduino Library for
- evive, Uno, Mega, and Nano – Dabble-Arduino
- ESP32 – Dabble-ESP32
depending on the board you are using.
Enabling Bluetooth Communication
To enable Bluetooth communication, you have to initialize serial communication using the following code:
- For evive and Arduino Mega, Uno and Nano
Dabble.begin(Baud_Rate);
Here Baud_Rate is the baud rate set for the Bluetooth module. With evive, you normally get 115200 baud rate modules.
- For ESP32
Dabble.begin("Bluetooth_Name");
In place of Bluetooth_Name enter name that you want to keep for Bluetooth of ESP32. Default name given in the library is “MyEsp32”.
Refreshing the data
To refresh the data that the device has got from the mobile app, you have to use the following line of code:
Dabble.processInput();
Functions
Music.play(key) – This function immediately plays the file with the key name passed as argument in it.
Music.addToQueue(key) – This function instructs the phone to play music associated with the key only after the completion of any ongoing music file. By using this command multiple times, you can create a list of various music files and play them one by one.
Music.stop() – Stop playing all the music files.
PictoBlox (Scratch) Blocks
There are two blocks available for music module in PictoBlox.
The “() music file ()” block is used to play the audio file for the key entered in the text box of the block. The drop -down of this block has two options :
- play – Selecting this option means the music file written in the block will be immediately played as soon as the block is executed.
- add to Queue – Selecting this option means the music file written in the block will be executed only after completing playing the ongoing music file.
“stop music” this block stops all the music file that is played from mobile.

Examples
evive
Mega, Uno, and Nano
ESP32
Projects

This project will show you how to make a surprise message gift box for your loved ones with a touch of tech.
- April 5, 2019 6:17 PM·