Make an Mp3 Player

From Wiki

Jump to: navigation, search

Kit List

Introduction:
Arduino advanced kit provided by ELECFREAKS is based on our starter kit to expand more and more popular modules owing the characteristics of plug and use without any requirement of soldering. We have well prepared six courses for learners to learn the usage of modules in an intersting environment which is better for stimulating your thinking mind. For example,Tetris games help us to study the usage of the LCD screen and Arduino program. Color picker used can help us to learn the color sensor as well as BLE Bluetooth communication and Android interface development ... Practical Course included LCD screen, sensor, MP3, BLE, WIFI, Android development, and image interaction (processing), make you open-minded!

Part3 Make an Mp3 Player

Product introduction:
AD-part-3.gif Use Arduino to make a Mp3 player by yourself would be interesting.
Mp3 player 1.png Mp3 player 2.png
Materials:
an Arduino board, an ADkey, an Mp3 module, of course, you still need to prepare an additional headset(general 3.5MM) and an SD card(FAT32 format, 32G or less)
*1xFreaduino Uno;
*1xADkey;
*1xMP3 module;

Parameter and IO definition:
1.3.3V power supply to mainboard
Uno 1.jpg
2.ADK access to board analog A0, G (ground), V (power supply), S (IO port).
3.Mp3Module的GND access to board black G port, VCC access to board red V port, TX access to board D4 port, RX access to board D5 port.
Working principles:
Via ADkey transferring to Uno board to control playing of Mp3 module, changing songs, and adjusting the volume. You need to know serial communication and connect the RX, TX of MP3 module to the TX, RX of Uno respectively. The rate is set to 9600bps. The file of JQ6500 in part3.zip has some communication introduction about MP3 module. What you must remember in mind is that the command must be hexadecimal data for normal communication. To insert SD card can immediately identify the inside MP3 musics. Send play command: 7E 02 0D EF to play it, but it must be sent in hexadecimal values, not strings.
Hardware Parameters JQ6500 Mini MP3 Module-F.jpg
== Communications Directive ==


1. Send commands directly no need return parameters


JQ6500 Mini MP3 Module-K.jpg

JQ6500 Mini MP3 Module-L.jpg



  • For example, for next, send: 7E 02 01 EF
  • For previous, send: 7E 02 02 EF
  • For play, send: 7E 02 0D EF


2.Parameter Query


JQ6500 Mini MP3 Module-M.jpg

JQ6500 Mini MP3 Module-O.jpg


  • Example: To read the volume, sent [7E 02 43 EF], it’ll directly return to volume (16 bits)
  • ADKEY resistance function: 0R PLAY 3.3K for Next, V + 6.2K for Pre, V-9.1K for mode switching.

  • Note 1: The folders inside USB and TF card must be named 01 02...99; the files inside the folders must be named 001 002 003....

Arduino code

part3.zip


 /*
 PART3  Make a Mp3 Player By Uno
 1. You need a Uno
 2. You need a Mp3 Module, using its Rx Tx pin to Uno's Tx Rx pin;
 3. You also need to add an ADK on Uno, control the player of the play & pause
 */
#include <SoftwareSerial.h>
#define mp3Rx  4
#define mp3Tx  5
SoftwareSerial mp3(mp3Rx,mp3Tx);
#define buttonA  0
#define buttonB  47
#define buttonC  91
#define buttonD  132
#define buttonE  546
int play=1;
// ADK listener
void keyListener() {
int value=analogRead(A0);
if(value<150&&value>100){
	delay(300);
	//play/pause//7E 02 0D EF//7E 02 0E EF
	if(play){
	mp3.write(0x7e);
	mp3.write(0x02);
	mp3.write(0x0d);
	mp3.write(0xef);
	play=0;
	}
	else{
		mp3.write(0x7e);
		mp3.write(0x02);
		mp3.write(0x0e);
		mp3.write(0xef);
		play=1;
	}
}
else if(value>500&&value<600){
	delay(300);
	//next//7E 02 01 EF
	mp3.write(0x7e);
	mp3.write(0x02);
	mp3.write(0x01);
	mp3.write(0xef);
}
if(value<20){
	delay(300);
   // value-//7E 02 05 EF
	mp3.write(0x7e);
	mp3.write(0x02);
	mp3.write(0x05);
	mp3.write(0xef);
}
else if(value>70&&value<100){
	delay(300);
	//pre//7E 02 02 EF
	mp3.write(0x7e);
	mp3.write(0x02);
	mp3.write(0x02);
	mp3.write(0xef);
 
}else if(value>30&&value<60){
	delay(300);
	//value+//7E 02 04 EF
	mp3.write(0x7e);
	mp3.write(0x02);
	mp3.write(0x04);
	mp3.write(0xef);
}
 
}
 
//The setup function is called once at startup of the sketch
void setup()
{
// Add your initialization code here
pinMode(A0,0);	//A0 pin adk
	            //mp3 module use RX(D0 pin)Tx(D1 pin)
mp3.begin(9600);//open MP3 serial
Serial.begin(9600);//open serial
}
 
// The loop function is called in an endless loop
void loop()
{
//Add your repeated code here
keyListener();// listen adk
if(Serial.available()){
mp3.print(Serial.readString());
}
if(mp3.available()){
Serial.print(mp3.readString());
}
}

Personal tools
Namespaces
Variants
Actions
Navigation
Support
Toolbox