Hardware Reference
In-Depth Information
pinMode(2,OUTPUT); // RFID ENABLE pin
digitalWrite(2, LOW); // Activates RFID reader
} // end void setup()
void loop() {
SoftwareSerial RFID = SoftwareSerial(rxPin,txPin);
RFID.begin(2400);
if((val = RFID.read()) == 10) { // check for header
bytesread = 0;
while(bytesread<10) { // read 10-digit code
val = RFID.read();
if((val == 10)||(val == 13)) { // check for a value of 10 or 13
break; // stop reading
}
code[bytesread] = val; // add the digit
bytesread++; // ready to read next digit
}
if(bytesread == 10) { // if 10-digit read is complete
Serial.print("TAG code is: "); // possibly a good TAG
Serial.println(code); // print the TAG code
}
bytesread = 0; // reset byte count
delay(500);
}
} // end void loop()
As shown in Figure 6-6 , this simulated sensor setup is very similar to the actual sensor: pin 2 on both Arduinos
are connected together, and pin 8 on the reader is connected to pin 9 on the sensor Arduino. Also, the 5V and GND
need to be connected.
Figure 6-6. RFID serial setup
Search WWH ::




Custom Search