Venus Supply Co., Ltd. Page 11
Example 2
In parallel mode, send a command to play 002.mp3 in folder 03.
const int P0 = 2;
const int P1 = 3;
const int P2 = 4;
const int P3 = 5;
const int P4 = 6;
const int P5 = 7;
const int P6 = 8;
const int P7 = 9;
const int BUSY = A4;
const int PL = A5;
void set_port() {
pinMode(P0, OUTPUT);
pinMode(P1, OUTPUT);
pinMode(P2, OUTPUT);
pinMode(P3, OUTPUT);
pinMode(P4, OUTPUT);
pinMode(P5, OUTPUT);
pinMode(P6, OUTPUT);
pinMode(P7, OUTPUT);
pinMode(PL, OUTPUT);
pinMode(BUSY,INPUT);
}
void send_CMD(unsigned char cmd) {
if( cmd&0x01 ) digitalWrite(P0, HIGH); //Bit 0
else digitalWrite(P0, LOW);
if( cmd&0x02 ) digitalWrite(P1, HIGH); //Bit 1
else digitalWrite(P1, LOW);
if( cmd&0x04 ) digitalWrite(P2, HIGH); //Bit 2
else digitalWrite(P2, LOW);
if( cmd&0x08 ) digitalWrite(P3, HIGH); //Bit 3
else digitalWrite(P3, LOW);
if( cmd&0x10 ) digitalWrite(P4, HIGH); //Bit 4
else digitalWrite(P4, LOW);
if( cmd&0x20 ) digitalWrite(P5, HIGH); //Bit 5
else digitalWrite(P5, LOW);
if( cmd&0x40 ) digitalWrite(P6, HIGH); //Bit 6
else digitalWrite(P6, LOW);
if( cmd&0x80 ) digitalWrite(P7, HIGH); //Bit 7
else digitalWrite(P7, LOW);
delay(100); digitalWrite(PL, LOW);
delay(100); digitalWrite(PL, HIGH);
}
boolean cmd_stop =false ;
void setup() {
set_port();
}
void loop() {
if ((digitalRead(BUSY) == HIGH) && (cmd_stop == false)) {
send_CMD(0xF3);
delay(200);
while(digitalRead(BUSY) == HIGH) {
send_CMD(0x02);
cmd_stop=true;
}
}
}
3. Set data pins according to sending command
5.
When BUSY is “High”, send 0xF3
and 0x02 to the module. To change
directory to 03 and play file 002.mp3.
1. Pin assignments
2. Pins
’
direction assignments
4. Call set_port()
to set pins’ direction