I m trying to use it on a GPS on a Pro Mini and it wasn't working with a simple test (code below) so I tried looping back pin 2 to 3 to see if got anything. I did not. I added a diagnostic to echo it it back and that works when I enable it so the Serial is working.
#include <NewSoftSerial.h>
#define rxPin 2
#define txPin 3
#define ledPin 13
boolean ledState = false;
int counter = 255; // To slow down the LED blinking
byte incomingByte = 0;
NewSoftSerial nss(rxPin, txPin);
void setup() // run once, when the sketch starts
{
Serial.begin(9600);
nss.begin(9600);
pinMode(ledPin, OUTPUT); // sets the digital pin as output
digitalWrite(ledPin,ledState);
delay(2000);
}
void loop() // run over and over again
{
// Blink the LED on pin 13 just to show we're alive
if (counter > 0) {
counter-=1;
} else {
ledState = ! ledState;
digitalWrite(ledPin,ledState);
counter=255;
}
// Read from the hardware UART.
// If any data is available, write it out through the software serial
if (Serial.available() > 0) {
incomingByte = Serial.read();
//Serial.print( incomingByte, BYTE);
nss.print(incomingByte);
}
// Read from software serial.
// If any data is available, write it out through the hardware UART
if (nss.available() > 0) {
incomingByte = nss.read();
Serial.print(incomingByte);
}
delay(1);
}