[Solved]: Confused by softserial

Hi All

Something must have fallen on my head ... why does something this simple not work .. I copied the serial echo example

/*
  Software serial multple serial test
 
 Receives from the hardware serial, sends to software serial.
 Receives from software serial, sends to hardware serial.
 
 The circuit: 
 * RX is digital pin 10 (connect to TX of other device)
 * TX is digital pin 11 (connect to RX of other device)
 
 Note:
 Not all pins on the Mega and Mega 2560 support change interrupts, 
 so only the following can be used for RX: 
 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69
 
 Not all pins on the Leonardo support change interrupts, 
 so only the following can be used for RX: 
 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).
 
 created back in the mists of time
 modified 25 May 2012
 by Tom Igoe
 based on Mikal Hart's example
 
 This example code is in the public domain.
 
 */
#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

void setup()  
{
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


  Serial.println("Goodnight moon!");

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  mySerial.println("Hello, world?");
}

void loop() // run over and over
{
  if (mySerial.available())
    Serial.write(mySerial.read());
  if (Serial.available())
    mySerial.write(Serial.read());
}

Plugged in a UNO, uploaded and no matter what I try all I get is "Goodnight moon!" on serial monitor, no "Hello World" and nothing that is typed is echo'ed

I've run blink led against all my pins and they seem to be working and am assuming the board i fine.

Tx

Software Serial disables interrupts when its running, so sending from the hardware serial port to the Software Serial Port will work
but the reverse wont , as the hardware port needs interrupts to be enabled to receive data.

What have you connected to pins 10 and 11 that will display the output from SoftwareSerial?

...R

Nothing, the example at http://arduino.cc/en/Tutorial/SoftwareSerialExample where the code comes from indicates its not required, the input from HW serial is written to SW serial which echo's it back to HW serial. Hence I am confused that is does not work.

That example is rubbish and doesn't work as documented. It says there is no circuit required, which is wrong.

In order for that software to do anything useful, you need to run the sketch on TWO arduinos and connect the ground, and pins 10,11 (crossed over) and then open the serial monitor for both boards.

Thanks guys, I figured as much. I got it working last night using an old dial-up modem (remember those? lol) that I had lying around. Cut a null modem cable and patched it in. As you mentioned, a common ground is all important otherwise you still only get garbage coming through.

Oh and I obviously added a TTL-RS232 converter to the line.

Appreciate the help.

BTW,how do I mark a thread solved?

sveng:
BTW,how do I mark a thread solved?

Go back to your first post and click modify. Then add the word SOLVED to the title. Leave the rest of the title text in place so others aren't confused.

...R