Pages: [1]   Go Down
Author Topic: Parallax RFID Scanner  (Read 165 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 1
Posts: 81
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Having trouble getting my scanner running.  I have searched this form and found this code but it will not compile
The error is
NewSoftSerial does not name a type                 (not sure what this means)

Code:
#include "NewSoftSerial.h"
#define txPin 6
#define rxPin 8

//Reader/Writer Commands
#define RFID_READ 0x01
//#define RFID_WRITE 0x02
//#define RFID_LEGACY 0x0F

NewSoftSerial mySerial(rxPin, txPin);
int  val = 0;
//char code[6];     //Note this is 11 for the extra null char?
//int bytesread = 0;
//int flag = 0;

//Tags
//char TAG1[11] = "0800E28C60";
//char TAG2[11] = "0800D9E43E";

void setup()
{
  Serial.begin(9600);
  mySerial.begin(9600);

  //  pinMode(2, OUTPUT);
  //  pinMode(4, OUTPUT);
  pinMode(txPin, OUTPUT);     //pin 6
  pinMode(rxPin, INPUT);      //pin 8

  Serial.println("RFID Read/Write Test");
}

void loop()
{
  mySerial.print("!RW");
  mySerial.print(RFID_READ, BYTE);
  mySerial.print(3, BYTE);

  //0th read
  if(mySerial.available() > 0) {          // if data available from reader
    val = mySerial.read();
    if(val != 255){
      Serial.print("Error Code:");
      Serial.println(val, HEX);
    }
  }

  //1st byte
  if(mySerial.available() > 0) {          // if data available from reader
    val = mySerial.read();
    if(val != 255){
      Serial.print("1st:");
      Serial.println(val, HEX);
    }
  }

  //2nd byte
  if(mySerial.available() > 0) {          // if data available from reader
    val = mySerial.read();
    if(val != 255){
      Serial.print("2nd:");
      Serial.println(val, HEX);
    }
  }

  //3rd byte
  if(mySerial.available() > 0) {          // if data available from reader
    val = mySerial.read();
    if(val != 255){
      Serial.print("3rd:");
      Serial.println(val, HEX);
    }
  }

  //4th byte
  if(mySerial.available() > 0) {          // if data available from reader
    val = mySerial.read();
    if(val != 255){
      Serial.print("4th:");
      Serial.println(val, HEX);
    }
  }

  delay(500);                       // wait for a 1/2 second
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8975
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It means you don't have the NewSoftSerial library installed.  You should change NewSoftSerial to SoftwareSerial which comes with Arduino 1.0.x.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Pages: [1]   Go Up
Jump to: