Arduino-Morse翻译器的串行信号能传送到文本到语音程序吗?

Arduino-Morse翻译器的串行信号能传送到文本到语音程序吗?,arduino,Arduino,我有Arduino摩尔斯电码翻译的工作代码。无论写入串行监视器的内容是什么,都会闪烁和蜂鸣,并将其输入串行监视器。我想添加的代码还可以将Arduino闪烁的字母/标点符号移植回一个文本到语音程序中,我有一个简单的TTS阅读器。可能吗 `//Sketch 5_05WORKS Morse Interpreter including punctuation int ledPin = 13; int dotDelay = 250; //set the delay to a quarter se

我有Arduino摩尔斯电码翻译的工作代码。无论写入串行监视器的内容是什么,都会闪烁和蜂鸣,并将其输入串行监视器。我想添加的代码还可以将Arduino闪烁的字母/标点符号移植回一个文本到语音程序中,我有一个简单的TTS阅读器。可能吗

 `//Sketch 5_05WORKS   Morse Interpreter including punctuation


int ledPin = 13;
int dotDelay = 250; //set the delay to a quarter second

char ch;
byte newch;  //transposed punctuation values

char* letters[] =                                                // Letters A-Z
                  {
                    ".-", "-...", "-.-.", "..", ".",                         
                     "..-.", "--.", "....", "..",
                     ".---", "-.-", ".-..", "--", "-.",                    
                     "---", ".--.", "--.-", ".-.",
                     "...", "-", "..-", "...-", ".--",                     
                     "-..-", "-.--", "--.."
                  };

char* numbers[] =                                              // numbers 0-9         
                  {
                    "-----", ".----", "..---", "...--", "....-",  
                    ".....", "-....", "--...", "---..", "----."
                  };             

char* punct[] =                                                // punctuation marks
                  {
                   ".-.-.-", "--..--", ".----.",  "..--..",       //  .  ,   '   ?    
                   "-.--.", "-.--.-", "-.-.--", "-.-.-.",        //  (  )   !   ;
                   "---...", ".-..-.", ".--.-.", "-....-",        //  :  "  @  -
                   "..--.-", ".-.-.", "...-..-", "-...-",         //  _  +  $  =
                   ".-..."                                        //  &





                    ".-.-.-", "--..--", "..--..", ".----.",          //  (punctuation marks) . , ? '
                       "-.-.--", "-.--.", "-.--.-", ".-...",            //    ! ( ) &
                       "---...", "-.-.-.", "-...-", ".-.-.",            //    : ; = +
                       "-....-", "..--.-", ".-..-.", "...-..-",          //     - _ " $
                       ".--.-."                                         //    @
                  }; 


void setup()                                                                
{
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
  Serial.println("To send text to be displayed in Morse Code, type words above and press Send");
}

void loop()
{

  if (Serial.available() > 0)
  {
      ch = Serial.read();                                        //read a single letter

      if (ch >= 'a' && ch <= 'z')                              // is it lower case letter?
   {
      flashSequence(letters [ch - 'a']);
   }
  else if (ch >= 'A' && ch <= 'Z')                           // is it a capital letter?
   {
      flashSequence(letters [ch - 'A']);
   }
  else if (ch >= '0' && ch <= '9')                          // is it a number?
   {
      flashSequence (numbers[ch - '0']);
   }
  else if (ch >= 33  &&  ch <=  95)                      // is it punctuation?   
   {

      punctuationTranspose();
      flashSequence (punct[newch]); 

   }
    else if (ch == ' ')                                          // is it a blank space?
   {
     delay(dotDelay * 4);                                    //gap between words
   }
  {    
     Serial.print(ch);
   }
  }
 }

void flashSequence (char* sequence)

{
  int i = 0;
  while  (sequence[i] != NULL)
  {
    flashDotOrDash(sequence[i]);
    i++;
  }
  delay(dotDelay * 3);                                     //gap between letters
}

void flashDotOrDash (char dotOrDash)
{
  digitalWrite(ledPin, HIGH);
  if (dotOrDash == '.')
  {
    delay (dotDelay);
  }
  else                                                           // must be a -
  {
    delay (dotDelay *2);                                  
  }
  digitalWrite(ledPin, LOW);
  delay(dotDelay);                                         //gap between flashes
}

byte punctuationTranspose()
{
  switch(ch)
  {
  case 1:
  ch=='.';
  newch= 0;
  break; 

  case 2:
  ch==',';
  newch= 1;
  break;

  case 3:
  ch==39;
  newch= 2;
  break;

  case 4:
  ch=='?';
  newch= 3;
  break;

  case 5:
  ch=='(';
  newch= 4;
  break;

  case 6:
  ch==')';
  newch= 5;
  break;

  case 7:
  ch=='!';
  newch= 6;
  break;

  case 8:
  ch==';';  
  newch= 7;
  break;

  case 9:
  ch==':';
  newch= 8;
  break;

  case 10:
  ch=='"';
  newch= 9;
  break;

  case 11:
  ch=='@';
  newch= 10;
  break;

  case 12:
  ch=='-';
  newch= 11;
  break;

  case 13:
  ch=='_';
  newch= 12;
  break;

  case 14:
  ch=='+';
  newch= 13;
  break;

  case 15:
  ch=='$';
  newch= 14;
  break;

  case 16:
  ch=='=';  
  newch= 15;
  break;

  case 17:
  ch=='&';
  newch= 16;
  break;

  return newch;
  }
}` 

是的,这是可能的。一种方法是使用其中一种。

是的,事实上这是非常可能的!对于这样的项目,TTS是非常基本的,您只需要对c语言有足够的了解,就可以将一些库连接到Arduino的输出:

TOMATO,我下载了Processing和FreeTTS,正在对它们进行审查。处理看起来非常像ArduinoAPI。感谢您的帮助。任何进一步的建议将不胜感激,并有助于缩短学习曲线!