Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SoftwareSerial.h>
- #define RX_PIN 8
- #define TX_PIN 9
- SoftwareSerial mySerial(RX_PIN, TX_PIN);
- void setup() {
- mySerial.begin(9600);
- sendMP3cmd(0x0C,0x00); // reset mp3 modulu
- _delay_ms(50);
- sendMP3cmd(0x09,0x02); // soubory jsou na SD karte
- _delay_ms(20);
- sendMP3cmd(0x06,0x1F); // nastav hlasitost
- _delay_ms(20);
- sendMP3cmd(0x03,0x01); // prehraj 1 skladbu
- }
- void loop() {
- // nic ....
- }
- void sendMP3cmd(uint8_t cmd, uint16_t par) // tvorba prikazu pro mp3 prehravac - netreba popisu - viz datasheet
- {
- // CMD ACK MSB LSB CMSB LMSB EOF
- uint8_t command[] = {0x7E, 0xFF, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xEF}; // buffer
- command[3]=cmd;
- command[5]=(uint8_t)(par>>8);
- command[6]=(uint8_t)(par & 0x00ff);
- uint16_t crc=0x0000;
- for (uint8_t a=1; a <=6 ; a++) crc-=command[a];
- command[7]=(uint8_t)(crc>>8);
- command[8]=(uint8_t)(crc & 0x00ff);
- for (uint8_t a=0; a<10; a++) mySerial.write(command[a]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement