Player MP3 Serial Catalex para Arduino UNO: Configuração e Controle Fáceis
Componentes e Materiais
| Componente | Quantidade |
|---|---|
| Arduino UNO | 1 |
| Player MP3 Serial da Catalex (v1.0) | 1 |
| Cartão MicroSD com músicas (MP3/WAV) | 1 |
Aplicativos e Serviços Online
- Arduino IDE
Sobre o Projeto
Como Usar o SERIAL MP3 PLAYER V1.0 da CATALex
Primeiro, baixe a biblioteca SoftwareSerial.h (já inclusa na IDE).
Defina os pinos de conexão e inicie a comunicação serial:
#define ARDUINO_RX 5 // Conectar ao TX do módulo MP3
#define ARDUINO_TX 6 // Conectar ao RX do módulo
SoftwareSerial mySerial(ARDUINO_RX, ARDUINO_TX);
Comandos Principais (do Datasheet)
O módulo entende comandos no formato 0x7E FF 06 comando 00 00 00 EF. Abaixo os principais definidos:
NEXT_SONG (0x01)– Próxima músicaPREV_SONG (0x02)– Música anteriorCMD_PLAY_W_INDEX (0x03)– Toca por índice (requer número da música)VOLUME_UP_ONE (0x04)/VOLUME_DOWN_ONE (0x05)CMD_SET_VOLUME (0x06)– Define volume (0 a 30 / 0x1E)CMD_PLAY_WITHVOLUME (0x22)– Toca música com volume específicoCMD_SEL_DEV (0x09)– Seleciona dispositivo de armazenamento (ex:DEV_TF 0x02para cartão TF)CMD_PLAY (0x0D)/CMD_PAUSE (0x0E)/STOP_PLAY (0x16)CMD_PLAY_WITHFOLDER (0x0F)– Toca pasta/arquivo específicoSET_CYCLEPLAY (0x19)– Repetição
Função de Envio de Comandos
static int8_t Send_buf[8] = {0};
void sendCommand(int8_t command, int16_t dat) {
delay(20);
Send_buf[0] = 0x7E;
Send_buf[1] = 0xFF;
Send_buf[2] = 0x06;
Send_buf[3] = command;
Send_buf[4] = 0x00; // 0x00 = sem feedback, 0x01 = com feedback
Send_buf[5] = (int8_t)(dat >> 8); // data high
Send_buf[6] = (int8_t)(dat); // data low
Send_buf[7] = 0xEF;
for (uint8_t i = 0; i < 8; i++) mySerial.write(Send_buf[i]);
}
Setup e Loop
void setup() {
Serial.begin(9600);
mySerial.begin(9600);
delay(500);
sendCommand(CMD_SEL_DEV, DEV_TF); // Seleciona cartão TF
delay(200);
}
void loop() {
// Toca a primeira música (índice 1) com volume 15 (0x0F)
sendCommand(CMD_PLAY_WITHVOLUME, 0x0F01);
delay(1000000); // Repete a cada ~16 min (apenas para teste)
}
Como Carregar Músicas no Cartão SD
O chip lê arquivos .mp3 ou .wav em ordem alfabética. Para controle preciso:
- Crie pastas nomeadas
01,02, etc. - Nomeie as músicas como
001nome.mp3,002outra.mp3dentro das pastas.
Assim, você sabe exatamente qual pasta/música será reproduzida.
Código Completo de Teste
// Reorganizado por Javier Muñoz 10/11/2016
#include <SoftwareSerial.h>
#define ARDUINO_RX 5
#define ARDUINO_TX 6
SoftwareSerial mySerial(ARDUINO_RX, ARDUINO_TX);
// ... (definições dos comandos iguais às acima) ...
static int8_t Send_buf[8] = {0};
void setup() {
Serial.begin(9600);
mySerial.begin(9600);
delay(500);
sendCommand(CMD_SEL_DEV, DEV_TF);
delay(200);
}
void loop() {
sendCommand(CMD_PLAY_WITHVOLUME, 0x0F01);
delay(1000000);
}
void sendCommand(int8_t command, int16_t dat) {
delay(20);
Send_buf[0] = 0x7e;
Send_buf[1] = 0xff;
Send_buf[2] = 0x06;
Send_buf[3] = command;
Send_buf[4] = 0x00;
Send_buf[5] = (int8_t)(dat >> 8);
Send_buf[6] = (int8_t)(dat);
Send_buf[7] = 0xef;
for (uint8_t i = 0; i < 8; i++) {
mySerial.write(Send_buf[i]);
Serial.print(Send_buf[i], HEX); // Debug no monitor serial
}
Serial.println();
}
Esquemático
Alimentação: 3.2V a 5V, consumo ~200mA. Consulte a imagem do datasheet para ligação detalhada.
Processo de manufatura
- Piano Mecânico: Fusão da Tradição Acústica com Precisão Automatizada
- Amplifique Mensagem da Crise de Manutenção: Baixe Versões Blues e Reggae da 'Canção da Crise de Manutenção'
- Construa uma Boneca Interativa Temática de Round 6 com Arduino UNO – Projeto DIY
- Construa um Spybot Controlado por Bluetooth com Arduino
- FlickMote: Controle Remoto IR por Gestos para Casa Inteligente
- DIY Arduino TV B-Gone: Controle Remoto Universal para Todas as TVs
- Construa um Relógio Mestre LED Personalizado com Alarme – Visível a 12 Metros
- Find Me: Localizador Inteligente de Objetos com Arduino e Bluetooth
- Soluções de Energia Otimizadas para Projetos Arduino
- Como Reproduzir Áudio com Arduino UNO e DFPlayer Mini – Guia Passo a Passo