I'm working with the RC522 module.
I am using it to toggle a LED but although it detects the card I cant get the IF loop to work that should show the serial number....
/*
PINOUT:
RC522 MODULE Uno/Nano MEGA
SDA D10 D9
SCK D13 D52
MOSI D11 D51
MISO D12 D50
IRQ N/A N/A
GND GND GND
RST D9 D8
3.3V 3.3V 3.3V
*/
/* Include the standard Arduino SPI library */
#include <SPI.h>
/* Include the RFID library */
#include <RFID.h>
/* Define the DIO used for the SDA (SS) and RST (reset) pins. */
#define SDA_DIO 53
#define RESET_DIO 5
/* Create an instance of the RFID library */
RFID RC522(SDA_DIO, RESET_DIO);
int powerPin =2;
int powerpinRead;
int prevpowerpinRead = LOW;
int powerpinState = LOW;
long time = 0; // the last time the output pin was toggled
long debounce = 200; // the debounce time, increase if the output flickers
void setup()
{
Serial.begin(9600);
/* Enable the SPI interface */
SPI.begin();
/* Initialise the RFID reader */
RC522.init();
pinMode(powerPin, OUTPUT);
}
void loop()
{
powerpinRead =RC522.isCard();
Serial.println (powerpinRead);
if (powerpinRead == HIGH && prevpowerpinRead == LOW && millis() - time > debounce)
{
if (powerpinState == HIGH)
powerpinState = LOW;
else
powerpinState = HIGH;
time = millis();
}
digitalWrite(powerPin, powerpinState);
prevpowerpinRead = powerpinRead;
/* Has a card been detected? */
if (RC522.isCard())
{
/* If so then get its serial number */
RC522.readCardSerial();
Serial.println("Hello kevin");
for(int i=0;i<5;i++)
{
Serial.print(RC522.serNum[i],DEC);
//Serial.print(RC522.serNum[i],HEX); //to print card detail in Hexa Decimal format
}
Serial.println();
Serial.println();
}
delay(500);
}