Using Pins 1 and 0 as inputs

Hi everybody:

I am finishing a project now, and I used all pins in arduino (I even used the analog as digitals) with SD card, 4x4keypad and a LCD diplay. Leaving me with only pins 0 and 1 for a RFID reader (RDM 6300).

Pretty Simple I used, this and it works:

/*------------------------------------------------------------------
This is a sample code for RDM630 RFID reader by Spekel(Spekel.se)
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
http://creativecommons.org/licenses/by-nc-sa/3.0/
-------------------------------------------------------------------*/
#include <SoftwareSerial.h>
#define rxPin 0
#define txPin 1
char code[20];
int val = 0;
int bytesread = 0;
//------------------------------------
//create a Serial object RFID
SoftwareSerial RFID= SoftwareSerial(rxPin, txPin);

void setup()
{
  Serial.begin(9600);
  Serial.println("Serial Ready");
  RFID.begin(9600);
  Serial.println("RFID Ready");
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
}
void loop()
{
  val = 0;
  bytesread = 0;

  while(bytesread < 12)
  {
    // read 12 digit code
    val = RFID.read();
    if(val == 3)
    { // if header or stop bytes before the 10 digit reading
      break; // stop reading
    }

    if(val != 2)
    {
      code[bytesread] = val; // add the digit
      bytesread++; // ready to read next digit
      code[bytesread] = '\0'; // add the NULL
    }
  }

  if(bytesread >= 12)
  { // if 12 digit read is complete
    Serial.print("Tag: [");
     delay(3000);
    for(int i=0; code[i]!='\0' ; i++)
    {
      Serial.print(code[i]);
    }
    Serial.println("]"); //print the whole 13 bytes
  }
  
  delay(3000);
}

But when Inserted to my complete code for the project its doesnt read. I understand I am using the two pins used for serial communication here… basically I only need one for the TX for my RFID reader…

For some weird reason its not working… Any help here?

The code for the whole project is basically, Show the RFID reading on lcd and storing it in a SD card.

Serial.begin uses 0,1 to talk to the PC.
You have defined 0,1 right on top of that.
Pick one or the other. Preferably hardware serial with Serial.begin.
You can use hardware serial to receive from RFID and to transmit to the PC at the same time - just don't connect Tx to the RFID so it doesn't see the Serial.print statements.
Similarly, don't type anything in the serial monitor so it doesn't interfer with you RFID messages.
Use Serial.available( ) to check for bytes coming in from the RFID before using Serial.read to read them.

CrossRoads:
Serial.begin uses 0,1 to talk to the PC.
You have defined 0,1 right on top of that.
Pick one or the other. Preferably hardware serial with Serial.begin.
You can use hardware serial to receive from RFID and to transmit to the PC at the same time - just don’t connect Tx to the RFID so it doesn’t see the Serial.print statements.
Similarly, don’t type anything in the serial monitor so it doesn’t interfer with you RFID messages.
Use Serial.available( ) to check for bytes coming in from the RFID before using Serial.read to read them.

Hey thanks for the reply, and sorry for the long time to reply back to you.

I modified the code with the information you told me, also I only connected the Rx pin.

This is the code now:

/*------------------------------------------------------------------
This is a sample code for RDM630 RFID reader by Spekel(Spekel.se)
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
http://creativecommons.org/licenses/by-nc-sa/3.0/
-------------------------------------------------------------------*/
#include <SoftwareSerial.h>
char code[20];
int val = 0;
int bytesread = 0;
//------------------------------------

void setup()
{
  Serial.begin(9600);
  Serial.println("Serial Ready");
  Serial.println("RFID Ready");
}
void loop()
{
  val = 0;
  bytesread = 0;
  if  (Serial.available())
{
  while(bytesread < 12)
  {
    // read 12 digit code
   
    val = Serial.read();
    if(val == 3)
    { // if header or stop bytes before the 10 digit reading
      break; // stop reading
    }

    if(val != 2)
    {
      code[bytesread] = val; // add the digit
      bytesread++; // ready to read next digit
      code[bytesread] = '\0'; // add the NULL
    }
  }

  if(bytesread >= 12)
  { // if 12 digit read is complete
    Serial.print("Tag: [");
    for(int i=0; code[i]!='\0' ; i++)
    {
      Serial.print(code[i]);
    }
    Serial.println("]"); //print the whole 13 bytes
  }
}
  delay(3000);
}

Its not working… any idea?

Take this out, you are not using SoftwareSerial anywhere
#include <SoftwareSerial.h>

Make sure you have enough data available to read 12 bytes before you start reading 12 bytes:
if (Serial.available()>=12)