How to Use: CHEAP Arduino Mp3 Shield for Making Robot Talk
by matthewh8 in Circuits > Robots
1318 Views, 22 Favorites, 0 Comments
How to Use: CHEAP Arduino Mp3 Shield for Making Robot Talk
![thumb.jpg](/proxy/?url=https://content.instructables.com/F86/DTXX/IJRHLFM4/F86DTXXIJRHLFM4.jpg&filename=thumb.jpg)
![How To: CHEAP Arduino mp3 Shield Tutorial for Beginners](/proxy/?url=https://content.instructables.com/FVB/CO6S/IJRHLI6F/FVBCO6SIJRHLI6F.jpg&filename=How To: CHEAP Arduino mp3 Shield Tutorial for Beginners)
This video is going to show you how to give your robot a voice for as cheap as possible. For some reason I had trouble, not only finding an inexpensive mp3 shield, but understanding the documentation as well. I figured I would share my code here to save people some time.
You will need an Elechouse mp3 shield, an SD card, and 2 small speakers (3 watt, 4 ohm work best).
Parts and code and be found here:
CODE:
![mp3shield.png](/proxy/?url=https://content.instructables.com/FN7/F1QV/IJRHLFM7/FN7F1QVIJRHLFM7.png&filename=mp3shield.png)
![speakers.jpg](/proxy/?url=https://content.instructables.com/F4S/9LPN/IJRHLFOD/F4S9LPNIJRHLFOD.jpg&filename=speakers.jpg)
![arduino.jpg](/proxy/?url=https://content.instructables.com/FQT/O6OG/IJRHLFOE/FQTO6OGIJRHLFOE.jpg&filename=arduino.jpg)
#include
SoftwareSerial Geno(7,8); // Rx , Tx
unsigned char Data[10]; unsigned char i;
void setup() { delay(1000); Geno.begin(9600); delay(1000); SetVolume(30);
}
void playTrack(int num){
delay(1000); Data[0] = 0x7E; Data[1] = 0x04; Data[2] = 0xA0; Data[3] = 0x00; Data[4] = 0x00 + num; Data[5] = 0x7E; Command(Data,5);
play_pause(); delay(3000); }
void SetVolume( int vol){ Data[0] = 0x7E; // START Data[1] = 0x03; // Length Not 0x02 Data[2] = 0xA7; // Command Data[3] = vol; // new volume Data[4] = 0x7E; // END Command(Data,5); }
void play_pause(){ Data[0] = 0x7E; // START Data[1] = 0x02; // Length Data[2] = 0xA3; // Command Data[3] = 0x7E; //Mode parameter Command(Data,4); }
void Command(unsigned char *Data, int length){ for(int i=0; i
void loop() {
playTrack(1);
playTrack(2);
}