NewSoftSerial Rx Corrupt

Hey.

I’m currently running this code just to test the NewSoftSerial library.

#include <NewSoftSerial.h>
NewSoftSerial CheckBinary(0,1);


void setup() {
  CheckBinary.begin(9600);

}

void loop() {
  if (CheckBinary.available()) CheckBinary.print(char(CheckBinary.read()));
  
}

I put in 12345678, and the last few characters come back corrupted. Any ideas?

I'm currently running this

On what processor / board?

Official Arduino Duemilanove connected by USB cable

Pin 0 and pin 1 are available through Serial (the hardware supported serial port)

Why are you using NewSoftSerial with these pins?

As a way to test NewSoftSerial.

I've had code connecting two arduinos together, but there was a portion not working - the NewSoftSerial in particular. This code is just to test the functionality.

I once read on a post by the author of NewSoftSerial as a way of testing functionality.

Serial works perfectly fine. NewSoftSerial doesn't.

EDIT: Author states here: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1252024653/5#5

Do you need more help?

Indeed, I have. Pin 8,2,3, and 9 have been tested with a normal operatioin script, but not that particular test script. Rx/Tx's a bit off, always.

I did it by setting an arduino to repeat "CHECK!" very quickily in the setup loop, and trying to receive it on a Software Rx Pin. I get "CHECK!" when I wiggle the jumper about, but when it's stable, nothing.

I get "CHECK!" when I wiggle the jumper about, but when it's stable, nothing.

OK. So fix the loose wire.

I did. Trust me, the wires are completely stable. When I get some movement on the wire, as in it ISN'T completely connected, it transmits.

Which pair of pins are you using for the "CHECK!" test?

Hardware Serial 0, 1 for the transmitter, so 1 for Tx.

SoftwareSerial, the pins stated above.

I'm reasonably certain it's not the wire - as the Tx LED on the Transmitter Arduino doesn't flash even when the Receiver Arduino says it receives some junk.

Wrote a bit of debug code.

From what I can tell, for future reference purposes, is that NewSoftSerial.read can't be polled too quickily, or else it'll just return -1 if it isn't ready, even at 9600 baud. I added a 12ms delay (Minimum) between each read and it works just fine.

From what I can tell, for future reference purposes, is that NewSoftSerial.read can't be polled too quickily, or else it'll just return -1 if it isn't ready, even at 9600 baud. I added a 12ms delay (Minimum) between each read and it works just fine.

Right! 16MHz is pretty fast. If you poll any serial port for a character that hasn't arrived yet, you won't get it! :)

BTW, I don't recommend the technique of using delay() to wait for serial characters. The best technique is to wait until NewSoftSerial::available() returns a non-zero value.

Also, if you have one Arduino communicating to another, make sure their Grounds are connected.

Mikal