で、ちょっと前に、DealeXtremeで「CATALEX社」のMP3プレイヤー部品を買いました。 - DXのページ
使い方が判らず、泣きました。マニュアル(pdf) - forum.arduino.cc
サンプルのどこでmicroSDのデータを参照してるの? ぐったりしてデータ置き用のカードを準備する気が起きなくなってしまいました。
ブランクが大きいって怖い。
さて、
/***********************************************************/
//Demo for the Serial MP3 Player by Catalex
//Hardware: Serial MP3 Player *1
//Board: Arduino UNO R3
//IDE: Arduino-1.0
//Function: To play the first song in the micro sd card.
//Store: http://www.aliexpress.com/store/1199788
// http://www.dx.com/
#include <softwareserial.h>
#define ARDUINO_RX 5//should connect to TX of the Serial MP3 Player module
#define ARDUINO_TX 6//connect to RX of the module
SoftwareSerial mySerial(ARDUINO_RX, ARDUINO_TX);
static int8_t Send_buf[8] = {0} ;
#define CMD_PLAY_W_INDEX 0x03
#define CMD_SET_VOLUME 0x06
#define CMD_SEL_DEV 0x09
#define DEV_TF 0x02
#define CMD_PLAY 0x0D
#define CMD_PAUSE 0x0E
#define CMD_SINGLE_CYCLE 0x19
#define SINGLE_CYCLE_ON 0x00
#define SINGLE_CYCLE_OFF 0x01
#define CMD_PLAY_W_VOL 0x22
void setup()
{
mySerial.begin(9600);
delay(500);//Wait chip initialization is complete
sendCommand(CMD_SEL_DEV, DEV_TF);//select the TF card
delay(200);//wait for 200ms
sendCommand(CMD_PLAY_W_VOL, 0x0F01);//play the first song with volume 15 class
}
void loop()
{
}
void sendCommand(int8_t command, int16_t dat)
{
delay(20);
Send_buf[0] = 0x7E; //starting byte
Send_buf[1] = 0xFF; //version
Send_buf[2] = 0x06; //the number of bytes of the command without starting byte and ending byte
Send_buf[3] = command; //
Send_buf[4] = 0x00;//0x00 = no feedback, 0x01 = feedback
Send_buf[5] = (int8_t)(dat >> 8);//datah
Send_buf[6] = (int8_t)(dat); //datal
Send_buf[7] = 0xEF; //ending byte
for(uint8_t i=0; i<8 i="" p=""> {
mySerial.write(Send_buf[i]) ;
}
}
8>
//Demo for the Serial MP3 Player by Catalex
//Hardware: Serial MP3 Player *1
//Board: Arduino UNO R3
//IDE: Arduino-1.0
//Function: To play the first song in the micro sd card.
//Store: http://www.aliexpress.com/store/1199788
// http://www.dx.com/
#include <softwareserial.h>
#define ARDUINO_RX 5//should connect to TX of the Serial MP3 Player module
#define ARDUINO_TX 6//connect to RX of the module
SoftwareSerial mySerial(ARDUINO_RX, ARDUINO_TX);
static int8_t Send_buf[8] = {0} ;
#define CMD_PLAY_W_INDEX 0x03
#define CMD_SET_VOLUME 0x06
#define CMD_SEL_DEV 0x09
#define DEV_TF 0x02
#define CMD_PLAY 0x0D
#define CMD_PAUSE 0x0E
#define CMD_SINGLE_CYCLE 0x19
#define SINGLE_CYCLE_ON 0x00
#define SINGLE_CYCLE_OFF 0x01
#define CMD_PLAY_W_VOL 0x22
void setup()
{
mySerial.begin(9600);
delay(500);//Wait chip initialization is complete
sendCommand(CMD_SEL_DEV, DEV_TF);//select the TF card
delay(200);//wait for 200ms
sendCommand(CMD_PLAY_W_VOL, 0x0F01);//play the first song with volume 15 class
}
void loop()
{
}
void sendCommand(int8_t command, int16_t dat)
{
delay(20);
Send_buf[0] = 0x7E; //starting byte
Send_buf[1] = 0xFF; //version
Send_buf[2] = 0x06; //the number of bytes of the command without starting byte and ending byte
Send_buf[3] = command; //
Send_buf[4] = 0x00;//0x00 = no feedback, 0x01 = feedback
Send_buf[5] = (int8_t)(dat >> 8);//datah
Send_buf[6] = (int8_t)(dat); //datal
Send_buf[7] = 0xEF; //ending byte
for(uint8_t i=0; i<8 i="" p=""> {
mySerial.write(Send_buf[i]) ;
}
}
8>
サンプルです。
0 件のコメント:
コメントを投稿