CCCPaste

RFID Scanner rev_02

/********* Pleasedontcode.com **********

	Pleasedontcode thanks you for automatic code generation! Enjoy your code!

	- Terms and Conditions:
	You have a non-exclusive, revocable, worldwide, royalty-free license
	for personal and commercial use. Attribution is optional; modifications
	are allowed, but you're responsible for code maintenance. We're not
	liable for any loss or damage. For full terms,
	please visit pleasedontcode.com/termsandconditions.

	- Project: RFID Scanner
	- Source Code NOT compiled for: ESP32 DevKit V1
	- Source Code created on: 2024-05-09 10:56:36

********* Pleasedontcode.com **********/

/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
	/* RC522 scan card and store card number */
/****** END SYSTEM REQUIREMENTS *****/

/****** DEFINITION OF LIBRARIES *****/
#include 
#include 

/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);

/***** DEFINITION OF I2C PINS *****/
const uint8_t Sceen_LCD1602I2C_I2C_PIN_SDA_D21 = 21;
const uint8_t Sceen_LCD1602I2C_I2C_PIN_SCL_D22 = 22;
const uint8_t Sceen_LCD1602I2C_I2C_SLAVE_ADDRESS = 39;

// Create an instance of the MFRC522 library
MFRC522 mfrc522(/*SS pin*/ 5, /*RST pin*/ 0); // Change SS and RST pins as needed

void setup(void)
{
  // put your setup code here, to run once:
  Serial.begin(9600);
  SPI.begin(); // Init SPI bus
  mfrc522.PCD_Init(); // Init MFRC522 card

  Serial.println("Scan a RFID card");
}

void loop(void)
{
  // put your main code here, to run repeatedly:
  // Look for new cards
  if (mfrc522.PICC_IsNewCardPresent() && mfrc522.PICC_ReadCardSerial())
  {
    Serial.println("A card is detected!");
    // Print UID of the card
    Serial.print("Card UID:");
    for (byte i = 0; i < mfrc522.uid.size; i++)
    {
      Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
      Serial.print(mfrc522.uid.uidByte[i], HEX);
    }
    Serial.println();
    mfrc522.PICC_HaltA(); // Halt PICC
  }
}

/* END CODE */