hi guyss,,
i am trying to make such an device which will convert given text input by serial monitor will be converted into
corresponding voice signal. i am using micro sd card for different voice signals for different text inputs.
i have written a piece of code this ,, have a watch and tell me how should i modify this as output of this code is not desirable
#include <SD.h> // need to include the SD library
//#define SD_ChipSelectPin 53 //example uses hardware SS pin 53 on Mega2560
#define SD_ChipSelectPin 4 //using digital pin 4 on arduino nano 328, can use other pins
#include <TMRpcm.h> // also need to include this library...
#include <SPI.h>
char receivedChar;
boolean newData = false;
TMRpcm tmrpcm; // create an object for use in this sketch
void setup(){
tmrpcm.speakerPin = 9; //5,6,11 or 46 on Mega, 9 on Uno, Nano, etc
Serial.begin(9600);
if (!SD.begin(SD_ChipSelectPin)) { // see if the card is present and can be initialized:
Serial.println("SD fail");
return; // don't do anything more if not
}
tmrpcm.play("hello.wav"); //the sound file "music" will play each time the arduino powers up, or is reset
tmrpcm.play("ard.wav");
tmrpcm.play("ino.wav");
Serial.begin(9600);
Serial.println("");
}
void recvOneChar() {
if (Serial.available() > 0) {
receivedChar = Serial.read();
newData = true;
}
}
void showNewData() {
if (newData == true) {
Serial.print("This just in ... ");
Serial.println(receivedChar);
newData = false;
}
}
void loop(){
recvOneChar();
showNewData();
if(Serial.available()){
if(Serial.read() == receivedChar){ //send the letter p over the serial monitor to start playback
tmrpcm.play("receivedChar");
}
}
}