NewSoftSerial will NOT work, arggg! Please Help

I am using an "Arduino Duemilanove", I copy the test sketch example right to a new blank Arduino sketch. It compiles and uploads fine, then in the serial monitor appears "GoodnightMoon!" only once, then that is it nothing more happens??? I thought I should make sure I have the latest version of "Arduino IDE" and the the latest version of "NewSoftSerial" so I went and got those downloaded and installed. I am just so confused here. Am I missing something? I also tried out the AFSoftSerial in hopes that might work, but same situation except 1 difference, with AFSoftSerial in the serial monitor "Goodnight Moon!" continuous keeps appearing/looping. Shouldn't "Hello, World?" also be appearing in the serial monitor if "NewSoftSerial" is working??? Please Help this is driving me crazy that everybody uses the library fine except I can't :0 :frowning: THANK YOU

You do not require the use of NewSoftSerial to send data back and forth from the arduino board to your PC using the Arduino IDE's serial monitor. That uses the build in hardware UART in the AVR controller chip and is 'hardwired' to pins 0 and 1, which is then routed to the on board USB serial converer chip and on to the PC via the USB cable. This is the same communications path that the Arduino IDE uses to upload sketches to your board.To use this comm channel in your Arduino sketch programs, you use the Serial commands that are part of the built-in arduino supplied functions. Here is the reference page for the Serial commands:

The NewSoftSerial library is used where you want to wire your arduino board to talk to some additional external device that uses serial communications, like a GPS module, or a Serial LCD display.

Does that clear anything up for you. Again you don't use NewSoftSerial library commands to talk to your PC, you use the arduino Serial commands.

Lefty

If you just want to experiment with the serial port/monitor, the below code will echo back what you send to the arduino from the serial monitor.

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

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(1);  //delay to allow byte to arrive in input buffer
    char c = Serial.read();
    readString += c;
  }

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

    readString="";
  } 
}

The whole idea of the library is adding a second (!) serial port on arduino-pins of your choice.
To monitor that port.... you'll need some extra hardware capable of receiving/sending data and
showing it to you.

Looking at the standard port only will indeed show you half the functions of the sketch.

I didn't have a serial LCD/GPS-module or something like that to address the second serial port
created by the sketch. I did have an old nokia cable that houses an usb <-> RS232 converter though.
By plugging it in the same PC and opening a second.... serial monitor (hyperterminal, putty, whatever)
I started seeing the Phrase "Hello world ?" in that window.

Connecting the second port directly to an RS-232 port of your PC unfortunately doesn't work. Arduino
works with 0 and 5 volt to communicate, the serial port on a computer (and lots of devices) -5 to +15 volt.
That could easily ruin the arduino, but with some extra hardware it's possible to work with such
rs232-ports as well.

Thank You for the responses. I am familiar with how the "Serial Port" (pins 0 & 1) work. I can assure they work fine in all aspects. Also I am familiar with the applications for the "NewSoftSerial" library and how it is intended to be used, this is of coarse why I need it to work. With that said, I am uncertain whether it is working properly, it just might be. So here in lies the heart of the problem to be more specific...

The following is a very basic sketch to implement "NewSoftSerial", please look it over and keep in mind I put a jumper wire from "Pin 3" to "Pin 2".

Now if I am correct, "mySerial" should print out directly into it's own buffer(Pin 3 to Pin 2). I have used this method with the original "SoftwareSerial" library with success, so the theory behind this sketch should be fine. Of coarse that old library has no buffer and so I "mySerial" printed out it's Tx into the "Serial" Rx which has a buffer. That would have been "Pin 3" to "Pin 0".
Then used a "while" loop to read each "char" from the buffer and print out to Serial Monitor. This following sketch has the same principle, just "mySerial" printed out it's Tx into the "mySerial" Rx where there should now be a buffer to hold "Hello, world". Then same "while" loop to read each "char" from the buffer and print out to Serial Monitor.

So this time only "Goodnight Moon" prints fine, then what the heck happens after that? I think either "mySerial" is not printing or it is printing but there is no "mySerial" buffer where there should be? Oh and printing "Goodnight Moon" isn't necessary it's just in there from the original example, which I modified to make simpler.

#include <NewSoftSerial.h>

NewSoftSerial mySerial(2, 3);

void setup()  
{
  pinMode(2, INPUT);
  pinMode(3, OUTPUT);
  
  Serial.begin(2400);          
  Serial.println("Goodnight moon!");

  mySerial.begin(2400);
  mySerial.println("Hello, world?");
}

void loop()                     
{
  char x;
  while (mySerial.available()) 
  {
    x = mySerial.read();  
    Serial.print(x);
    delay(500);
  }
}

Below is the sketch with "Software Serial" that works:

#include <SoftwareSerial.h>

SoftwareSerial mySerial = SoftwareSerial(2, 3);

void setup()
  {
    pinMode(2, INPUT);
    pinMode(3, OUTPUT);
    mySerial.begin(2400); 
    Serial.begin(2400);
  }

void loop()
  {
    char x;
    mySerial.print("testing");           
    while(Serial.available())    
      {                                
        x = Serial.read();                   
        Serial.println(x); 
        delay(500);        
      }
  }

Moderator edit: tidy up the end code tags.

I don't follow: if you're sending this out

mySerial.begin(4800);
mySerial.println("Hello, world?");

at 4800, how is this port supposed to receive at 9600?
Serial.begin(9600);

Seems like a data rate mismatch.

Ok well I'm thinking it shouldn't matter what baud rate you send data into the buffer or read it out of the buffer because it gets stored in the buffer. But anyways I went ahead and adjusted my post that contained the code so that both baud rates, mySerial & Serial, are matching. But still no difference.

I meant to post 2 separate sketches in my previous post but the ended up in the same "code window" if that's what it's called. So if you notice there is a sketch with "SoftwareSerial" and a sketch with "NewSoftSerial", the "NewSoftSerial" sketch is first as you'll see. But if someone wants to, you could copy the 2nd sketch with "SoftwareSerial", paste it in arduino and run it, then watch the Serial monitor as "testing" is spelled out letter by letter.
At that point, try copy and pasting the 1st sketch with "NewSoftSerial" into Arduino and run it... Ask yourself why isn't "Hello, world?" from the "NewSoftSerial" sketch, being spelled out on the Serial monitor in the same fashion???

That would probably make my post make more sense to whomever trying to helpfully troubleshoot it with me.
THANK YOU anyone who has a few minutes to possibly think this over. If you compare the two sketches side by side that would also help show how similar they are and how the outcomes I think should be the same.

I meant to post 2 separate sketches in my previous post but the ended up in the same "code window"

Is that better?

Yes thank you "Coding Badly" that separated the sketches nicely.

I've been thinking...is the hardware serial port capable of printing a software serial read, example: "Serial.print(mySerial.read())" ? One of these replies told me I need additional hardware to debug/monitor a software serial port, and well ok I can understand that sure BUT I don't see why I can't print out of "mySerial" Tx directly right into "mySerial" Rx's buffer...then follow it up with a "Serial.print(mySerial.read())" to read the 1st "char" in the mySerial's Rx buffer?

I'm trying to give a shorter version of my question with this reply than what I originally posted in case this little paragraph is easier to understand.

Logically, I could see why this one doesn't work

{
  pinMode(2, INPUT);
  pinMode(3, OUTPUT);
  
  Serial.begin(2400);          
  Serial.println("Goodnight moon!");   <<< here you've turned on the hardware UART, and I would expect that this whole
                                                             <<< message goes out before the program continues.

  mySerial.begin(2400);                      <<< now you start up the software UART, but its missed the whole message already
  mySerial.println("Hello, world?");
}

so when you get further on, the message is already sent and myserial() will never be active
As a test, try this:

void loop(){
 if (mySerial.available()>0) 
  {
    x = mySerial.read();  
    Serial.print(x);
  }
else {
Serial.print (".");
delay (500);
}
}

This should spit back what ever keys you type, and just print .... when nothing is received, so you can see nothing is received.

You wrote that, "Logically, I could see why this one doesn't work" and I sort of agree with you but the code was like that because I copied it from the "NewSoftSerial" official Example, so it's like why would they give that as an example if it won't work???

But I adjusted it as you said to give the software serial time to start up. I put a 1 second delay in after "mySerial.begin". I also tried the code you gave me to try and it doesn't work??? This is why I'm so frustrated, I looked at your code and thought "Oh sure I agree that should spit out what I type" BUT it doesn't. Neither the Tx or Rx of NewSoftSerial works.

I saw someone wrote that they had a similar problem and when they switched to an Arduino Uno then it works. I'm thinking this stupid NewSoftSerial won't work because I have an Arduino Duemilanove. I also tried all the same sketches with my Arduino Nano which is basically same thing(same chip) and same problems??? I wondering if everytime they "Update" NewSoftSerial they screw up the newest version so it isnt backwards compatible.

I have read many people with all kinds of problems with NewSoftSerial. Does anyone know if there is anything I can do short of having to buy a STUPID arduino Uno? THANK YOU somebody help because I need to use NewSoftSerial...

Oh also note that AFSoftSerial is also screwy and doesn't work properly, BUT does give me different results than NewSoftSerial. So how can the same exact sketches trying both different types of software serials give me different results showing up in the Serial Monitor??? Uggg this really sucks ya know...Oh and plain old just "SoftwareSerial" the original library with no buffer, WORKS PERFECTLY FINE!!! So what the heck NewSoftSerial people what are you doing top me, driving me nuts trying to figure this junk out.

Thank you anyone who has help

Sorry I can't help you more. My stuff's all inaccessible at the moment. Duemilanove and Uno use the same '328 processor. Maybe the difference is in the bootloader. But once your sketch starts up, the bootloader should not make a difference.
I'll see if I can wade thru to my electronics room tomorrow and rig up a test.

We're doing a lot of house re-arranging, first to get rid of couch to make room for some new armchairs and visiting relatives (and managed to take apart the dual-recliner couch, and reassemble the 2 arms, 1 back, reclining mechanism from one side and seat cushion from the other to make a single reclining chair!), and then today made arrangements to have a used baby grand piano delivered, so spent the rest of the day cleaning out another room to make room for the piano. Amazing how much stuff we've accumulated in the 21 years we've lived here, along with all the stuff for the kid.
Got me thinking tho, we've got boxes of erector set stuff, and boxes of lego, and lego motors & sensors & switches, got to be something I can create out of all that.