Advertisement
pleasedontcode

RFID Reader rev_01

May 9th, 2024
995
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: RFID Reader
  13.     - Source Code NOT compiled for: ESP32 DevKit V1
  14.     - Source Code created on: 2024-05-09 10:54:01
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* RC522 scan cards */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /****** DEFINITION OF LIBRARIES *****/
  24. #include <Wire.h>
  25. #include <MFRC522.h>  // Include the MFRC522 library
  26.  
  27. /****** FUNCTION PROTOTYPES *****/
  28. void setup(void);
  29. void loop(void);
  30.  
  31. /***** DEFINITION OF I2C PINS *****/
  32. const uint8_t Sceen_LCD1602I2C_I2C_PIN_SDA_D21 = 21;
  33. const uint8_t Sceen_LCD1602I2C_I2C_PIN_SCL_D22 = 22;
  34. const uint8_t Sceen_LCD1602I2C_I2C_SLAVE_ADDRESS = 39;
  35.  
  36. // Create an instance of the MFRC522 library
  37. MFRC522 mfrc522(/*SS pin*/ 5, /*RST pin*/ 4);  // Change the SS and RST pins as per your wiring
  38.  
  39. void setup(void)
  40. {
  41.   // put your setup code here, to run once:
  42.   Serial.begin(9600);
  43.   SPI.begin(); // Init SPI bus
  44.   mfrc522.PCD_Init(); // Init MFRC522 card
  45.  
  46.   Serial.println("Scan RFID card to get the UID...");
  47. }
  48.  
  49. void loop(void)
  50. {
  51.   // put your main code here, to run repeatedly:
  52.   // Look for new cards
  53.   if (mfrc522.PICC_IsNewCardPresent() && mfrc522.PICC_ReadCardSerial())
  54.   {
  55.     // Show UID on serial monitor
  56.     Serial.print("UID tag :");
  57.     String content = "";
  58.     for (byte i = 0; i < mfrc522.uid.size; i++)
  59.     {
  60.       content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
  61.       content.concat(String(mfrc522.uid.uidByte[i], HEX));
  62.     }
  63.     content.toUpperCase();
  64.     Serial.println(content);
  65.   }
  66. }
  67.  
  68. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement