Example Code for Arduino-MP3 Music Player
Last revision 2026/01/07
This article provides comprehensive guidance on building and programming an Arduino-MP3 music player using a Vortex Robot, including hardware and software setup, sample code, and instructions for adding songs.
Hardware Preparation
- Vortex Robot, SKU:ROB0116
- micro USB cable
Software Preparation
- Arduino IDE, Download link
Other Preparation Work
- Unscrew the screw and open the USB programming port.
- Turn on Vortex power switch, and plug in the Micro usb cable, it will install the driver automatically if you have installed Arduino IDE. If not, you can find it in the driver file in Arduino IDE folder-->Drivers folder.
- There is a switch close to the USB port, make sure the trigger is close to the USB side. This is MP3 switch, we'll teach you how to add new song in the following chapter.
- Open your Arduino IDE, select "Arduino UNO" and right "COM port" in Arduino IDE, now you can enjoy coding.
Sample Code
/***************************************************
Vortex V1.0 (Small robots like bread)
<https://www.dfrobot.com.cn/goods-1199.html>
***************************************************
This example show how to device mp3 player.
Created 2016-2-3
By Andy zhou <[email protected]>
version:V1.0
****************************************************/
/***********Notice and Trouble shooting***************
1.Connection and Diagram can be found here
<http://wiki.dfrobot.com.cn/index.php?title=(SKU:ROB0116)_Vortex%E5%8F%AF%E7%BC%96%E7%A8%8B%E6%9C%BA%E5%99%A8%E4%BA%BA#.E6.A0.B7.E4.BE.8B.E4.BB.A3.E7.A0.81>
2.This code is tested on vortex V1.0.
****************************************************/
#include <SoftwareSerial.h>
#include <VortexMp3.h>
#define MP3_VOLUME 0x10
void init(){
mp3.Init();
mp3.setVolume(MP3_VOLUME);
}
void setup() {
// put your setup code here, to run once:
init();
}
static int musicState = 1;
void loop(){
// put your main code here, to run repeatedly:
mp3.player(musicState);
musicState++;
if (musicState>=20){
musicState = 1;
}
delay(1000);
}
Additional Information
- Turn the switch trigger to the opposite side (away from the USB port).
- Connect Vortex to your computer via USB port. and it will appear a new flash disk.
- Rename your voice or your song file, and put them in the disk.
NOTE: The MP3 chip recognizes the file by the modified time, not its name, so you will need to rank the file again! Just cut all file outside, and move them in the disk in order. |
Was this article helpful?
