Quick serial sketch.

I'm hoping to get someone to make a quick Serial sketch for a Arduino Uno. I need to take a string of text that comes in on the serial port and pass it off to a software port that will be on Pins 2 and 3. Then lastly to have the string echoed on the Serial monitor. Thanks for your help. :slight_smile:

WIth a little effort on Google, you should be able to find a bazillion references for this code.

About as simple as it gets. You need to add the software serial code for pins 2 and 3.

// zoomkat 7-30-11 serial I/O string test
// type a string in serial monitor. then send or enter
// for IDE 0019 and later

/*Very simple serial test code. Copy and paste into the IDE code 
area. Upload via clicking the IDE upload arrow. When upload 
finished, open the serial monitor by clicking the serial monitor 
icon in the upper right of the IDE. Ensure 9600 baud rate is 
selected in the serial monitor. Type something in the serial 
monitor text box and send. What was typed in the text box should 
be sent back to the serial monitor display. */

String readString;

void setup() {
  Serial.begin(9600);
  Serial.println("serial test 0021"); // so I can keep track of what is loaded
}

void loop() {

  while (Serial.available()) {
    delay(2);  //delay to allow byte to arrive in input buffer
    char c = Serial.read();
    readString += c;
  }

  if (readString.length() >0) {
    Serial.println(readString);

    readString="";
  } 
}

Thank you vary much. Just what I needed. :slight_smile: