user26383: I am trying to manipulate a project and the simplest way to do what I am trying to do would be to use the existing code.  This code is designed to take an input from the serial monitor using serial.read() and manipulate it.  For example if I type hello into the serial monitor's command bar, the code would read it and manipulate it.  I was wondering if there is any way to create a serial command to run in the code which would act in a way as to bypass the serial monitor since this project is not going to be connected to a computer when it is in use.  The command will be the same every time and will be in response to a single switch input.
#include <avr/pgmspace.h>
#include <MorseEnDecoder.h>
#include <stdio.h>

// Pin mapping
const byte morseInPin = 7;      
const byte morseOutPin = 13;
String check = "";
String origin = "S";
const int maxItems = 3;
char myStr[] = "Help is Coming";
int x;
char myArray[maxItems], curChar;
char nextChar;
int i;
int y;

// Instantiate Morse objects
morseDecoder morseInput(morseInPin, MORSE_KEYER, MORSE_ACTIVE_LOW);
morseEncoder morseOutput(morseOutPin);

// Variables dealing with formatting the output somewhat
// by inserting CR's (carriage returns)
long lastTransmissionTime;
long currentTime;
boolean transmissionEnded = true; // Flag to mark old trans finished

// Minimum transmission pause time to insert carriage returns (CR)
// Adjust depending on Morse spd. IE 13 wpm = 646 ms btw words (no CR).
const long transmissionPaused   = 1000; // Suitable for 13 wpm?

void setup()
{
Serial.begin(9600);
Serial.println("Morse EnDecoder Geocache");

// Setting Morse speed in wpm - words per minute
// If not set, 13 wpm is default anyway
morseInput.setspeed(5);
morseOutput.setspeed(5);

lastTransmissionTime = (long)millis();

}


void loop()
{
currentTime = (long)millis();

// Need to call these once per loop
morseInput.decode();
morseOutput.encode();

// SEND MORSE (OUTPUT)
// Encode and send text received from the serial port (serial monitor)
if (Serial.available() && morseOutput.available())
{
// Get character from serial and send as Morse code
char sendMorse = Serial.read();
morseOutput.write(sendMorse);

// Not strictly needed, but used to get morseSignalString before it is      destroyed
// (E.g. for morse training purposes)
morseOutput.encode();

// Also write sent character + Morse code to serial port/monitor
Serial.write(' ');
Serial.write(sendMorse);
// Morse code in morseSignalString is now backwards
for (int y=morseOutput.morseSignals; y>0; y--)
{
  Serial.write(morseOutput.morseSignalString[y-1]);
}
}

// RECEIVE MORSE (INPUT)
// If a character is decoded from the input, write it to serial port
if (morseInput.available())
{

char receivedMorse = morseInput.read();
//Serial.print(receivedMorse);
// A little error checking    
if (receivedMorse == '#') Serial.println("< ERROR:too many morse   signals! >");
morseOutput.write('#');
morseOutput.encode();

//Create Array out of receivedMorse Chars

    curChar = 0;
    nextChar = receivedMorse;
    curChar +=nextChar;
    myArray[i] = curChar;
    check.concat(myArray[i]);
    Serial.println(check);

  //Check input and respond
  if (check == origin) 
  {
Serial.println("check = origin");

// Encode and send text set in myStr[x]

for (x = 0; x < sizeof(myStr) - 1; x++)    
{
char sendMorse = myStr[x];
morseOutput.write(sendMorse);

// Not strictly needed, but used to get morseSignalString before it is destroyed
// (E.g. for morse training purposes)
morseOutput.encode();

// Also write sent character + Morse code to serial port/monitor
Serial.write(' ');
Serial.write(sendMorse);
// Morse code in morseSignalString is now backwards
for (int y=morseOutput.morseSignals; y>0; y--)
{     
Serial.write(morseOutput.morseSignalString[y-1]);
}
}

  }


 if (receivedMorse == '#') Serial.println("< ERROR:too many morse signals! >");
 }
 // two strings not equal:
 if (check != origin) {

 }
 }

This is a morse code encoder and decoder.  I have adapted it to do a certain thing when a certain string of morse code is entered.  I am trying to get it to then encode and respond with a morse string, but the only way it is programmed to do such a thing is through the serial.read() command  There is a library that I am not sure how to attach, it can be found here
https://www.dropbox.com/s/eg21qmg0151gxz6/Morse_EnDecoder_2012.11.25.tar-2.gz?dl=0 this also includes all of the original codes.  My additions can be found directly under the comment //Create Array out of receivedMorse Chars and continuing to the bottom (The last 45 lines or so not including char, string, and int declarations).  I apologize if some of the edits I have made are hideous or "not in the spirit of the language".  I am a novice and a hobbyist.
The Code I have adapted will print my string exactly as it appears (myStr[]), however it will not encode it to Morse nor will it output it through the LED or the buzzer.  The 'serial.read()' command appears to work outside of my if statement, but really I have no idea how I would fix this.

user25539: The serial input is read into a variable.   
You could comment out the serial read and assign whatever value you need directly to the variable.  By commenting out the serial read, you will have a marker of where you made the changes.
This should work since you are saying the inputs are known and do not change.

26383: <p>I am trying to manipulate a project and the simplest way to do what I am trying to do would be to use the existing code.  This code is designed to take an input from the serial monitor using serial.read() and manipulate it.  For example if I type <em>hello</em> into the serial monitor's command bar, the code would read it and manipulate it.  I was wondering if there is any way to create a serial command to run in the code which would act in a way as to bypass the serial monitor since this project is not going to be connected to a computer when it is in use.  The command will be the same every time and will be in response to a single switch input.</p>

<pre><code>#include &lt;avr/pgmspace.h&gt;
#include &lt;MorseEnDecoder.h&gt;
#include &lt;stdio.h&gt;

// Pin mapping
const byte morseInPin = 7;      
const byte morseOutPin = 13;
String check = "";
String origin = "S";
const int maxItems = 3;
char myStr[] = "Help is Coming";
int x;
char myArray[maxItems], curChar;
char nextChar;
int i;
int y;

// Instantiate Morse objects
morseDecoder morseInput(morseInPin, MORSE_KEYER, MORSE_ACTIVE_LOW);
morseEncoder morseOutput(morseOutPin);

// Variables dealing with formatting the output somewhat
// by inserting CR's (carriage returns)
long lastTransmissionTime;
long currentTime;
boolean transmissionEnded = true; // Flag to mark old trans finished

// Minimum transmission pause time to insert carriage returns (CR)
// Adjust depending on Morse spd. IE 13 wpm = 646 ms btw words (no CR).
const long transmissionPaused   = 1000; // Suitable for 13 wpm?

void setup()
{
Serial.begin(9600);
Serial.println("Morse EnDecoder Geocache");

// Setting Morse speed in wpm - words per minute
// If not set, 13 wpm is default anyway
morseInput.setspeed(5);
morseOutput.setspeed(5);

lastTransmissionTime = (long)millis();

}


void loop()
{
currentTime = (long)millis();

// Need to call these once per loop
morseInput.decode();
morseOutput.encode();

// SEND MORSE (OUTPUT)
// Encode and send text received from the serial port (serial monitor)
if (Serial.available() &amp;&amp; morseOutput.available())
{
// Get character from serial and send as Morse code
char sendMorse = Serial.read();
morseOutput.write(sendMorse);

// Not strictly needed, but used to get morseSignalString before it is      destroyed
// (E.g. for morse training purposes)
morseOutput.encode();

// Also write sent character + Morse code to serial port/monitor
Serial.write(' ');
Serial.write(sendMorse);
// Morse code in morseSignalString is now backwards
for (int y=morseOutput.morseSignals; y&gt;0; y--)
{
  Serial.write(morseOutput.morseSignalString[y-1]);
}
}

// RECEIVE MORSE (INPUT)
// If a character is decoded from the input, write it to serial port
if (morseInput.available())
{

char receivedMorse = morseInput.read();
//Serial.print(receivedMorse);
// A little error checking    
if (receivedMorse == '#') Serial.println("&lt; ERROR:too many morse   signals! &gt;");
morseOutput.write('#');
morseOutput.encode();

//Create Array out of receivedMorse Chars

    curChar = 0;
    nextChar = receivedMorse;
    curChar +=nextChar;
    myArray[i] = curChar;
    check.concat(myArray[i]);
    Serial.println(check);

  //Check input and respond
  if (check == origin) 
  {
Serial.println("check = origin");

// Encode and send text set in myStr[x]

for (x = 0; x &lt; sizeof(myStr) - 1; x++)    
{
char sendMorse = myStr[x];
morseOutput.write(sendMorse);

// Not strictly needed, but used to get morseSignalString before it is destroyed
// (E.g. for morse training purposes)
morseOutput.encode();

// Also write sent character + Morse code to serial port/monitor
Serial.write(' ');
Serial.write(sendMorse);
// Morse code in morseSignalString is now backwards
for (int y=morseOutput.morseSignals; y&gt;0; y--)
{     
Serial.write(morseOutput.morseSignalString[y-1]);
}
}

  }


 if (receivedMorse == '#') Serial.println("&lt; ERROR:too many morse signals! &gt;");
 }
 // two strings not equal:
 if (check != origin) {

 }
 }
</code></pre>

<p>This is a morse code encoder and decoder.  I have adapted it to do a certain thing when a certain string of morse code is entered.  I am trying to get it to then encode and respond with a morse string, but the only way it is programmed to do such a thing is through the <code>serial.read()</code> command  There is a library that I am not sure how to attach, it can be found here
<a href="https://www.dropbox.com/s/eg21qmg0151gxz6/Morse_EnDecoder_2012.11.25.tar-2.gz?dl=0" rel="nofollow">https://www.dropbox.com/s/eg21qmg0151gxz6/Morse_EnDecoder_2012.11.25.tar-2.gz?dl=0</a> this also includes all of the original codes.  My additions can be found directly under the comment <code>//Create Array out of receivedMorse Chars</code> and continuing to the bottom (The last 45 lines or so not including char, string, and int declarations).  I apologize if some of the edits I have made are hideous or "not in the spirit of the language".  I am a novice and a hobbyist.</p>

<p>The Code I have adapted will print my string exactly as it appears (<code>myStr[]</code>), however it will not encode it to Morse nor will it output it through the LED or the buzzer.  The 'serial.read()' command appears to work outside of my if statement, but really I have no idea how I would fix this.</p>
 25539: <p>The serial input is read into a variable.   </p>

<p>You could comment out the serial read and assign <em>whatever</em> value you need directly to the variable.  By commenting out the serial read, you will have a marker of where you made the changes.</p>

<p>This should work since you are saying the inputs are known and do not change.</p>
