Serial vs SoftwareSerial problem

I am trying to adapt this code that I use to read data off the hardware serial to work with the software serial. Here is my code. I get garbage with I read pins 2 & 3 using software serial, but it reads correctly when I use the hardware serial on 0 & 1. Thanks.

#include <SoftwareSerial.h>

#define rxPin 2
#define txPin 3

SoftwareSerial softSerial =  SoftwareSerial(rxPin, txPin);

void setup()  {

  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);


void loop() {

  int data =;
  if (data != -1) {
  softSerial.print(data, BYTE);

You could try NewSoftSerial

a delay of 10ms at 9600 bps is nearly 10 bytes' worth.