ok..... so.. like 5 questions later, and deleting those 5 questions. all on this post.... this is what I ended up with. i can't believe it works. sooooo happy. all thats left is to see how far it can go and. yay!
i kinda changed stuff tho.
#include <SPI.h>//include the SPI bus library
#include <MFRC522.h>//include the RFID reader library
#include <EEPROM.h>
#define SS_1_PIN 5 //slave select pin
#define SS_2_PIN 6 //slave select pin
#define RST_PIN 7 //reset pin
#define NR_OF_READERS 2
byte ssPins[] = {SS_1_PIN, SS_2_PIN};
//MFRC522 mfrc522(SS_PIN, RST_PIN); // instatiate a MFRC522 reader object.
MFRC522 mfrc522[NR_OF_READERS]; // Create MFRC522 instance.
MFRC522::MIFARE_Key key; //create a MIFARE_Key struct named 'key', which will hold the card information
unsigned long intervalval=4000;
byte nuidPICC[4];
int PasswordBlock = 2; //this is the block number we will write into and then read. Do not write into 'sector trailer' block, since this can make the block unusable.
int BanKeyBlock = 4;//this is the block that stores a key programmed into a tag to be deactivated when that tag is used
byte blockcontent[16] = {"ppcc"}; //an array with 16 bytes to be written into one of the 64 card blocks is defined!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
byte deactivatecardblockcontent[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};//all zeros. This can be used to delete a block.
byte readbackblock[18]; //This array is used for reading out a block. The MIFARE_Read method requires a buffer that is at least 18 bytes to hold the 16 bytes of a block.
String txt; //This is where we store block 2, the password
uint8_t reader;
void setup() {
//create A0 as led
pinMode(4, OUTPUT);//led
pinMode(3, OUTPUT);//RPWM (right pwm on motor controller)
pinMode(2, INPUT_PULLUP);//signal from sensors
pinMode(8,OUTPUT);//LPWM (left pwm on motor controller)
digitalWrite(8, LOW);
digitalWrite(3, LOW);
Serial.begin(9600); // Initialize serial communications with the PC
SPI.begin(); // Init SPI bus
for (reader = 0; reader < NR_OF_READERS; reader++) {
mfrc522[reader].PCD_Init(ssPins[reader], RST_PIN); // Init each MFRC522 card
Serial.print(F("Reader "));
Serial.print(reader);
Serial.print(F(": "));
mfrc522[reader].PCD_DumpVersionToSerial();
}
Serial.println("Scan a MIFARE Classic card");
for (byte i = 0; i < 6; i++) {
key.keyByte[i] = 0xFF; //keyByte is defined in the "MIFARE_Key" 'struct' definition in the .h file of the library
}
}
void loop() {
// Look for new cards (in case you wonder what PICC means: proximity integrated circuit card)
for (reader = 0; reader < NR_OF_READERS; reader++){
if (mfrc522[reader].PICC_IsNewCardPresent() && mfrc522[reader].PICC_ReadCardSerial()) {
Serial.println("found card");
//Store Card UID
for (byte i = 0; i < 4; i++) {
nuidPICC[i] = mfrc522[reader].uid.uidByte[i];
}