Untitled
unknown
plain_text
2 years ago
1.4 kB
8
Indexable
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <MFRC522.h>
#define RST_PIN 5 // Connect RST to digital pin 5
MFRC522 mfrc522; // Create MFRC522 instance
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
void setup()
{
Serial.begin(9600); // Initialize serial communications with the PC
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522 card
lcd.init(); // initialize the lcd
lcd.backlight();
lcd.setCursor(3,0);
lcd.print("Hello, world!");
}
void loop()
{
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent() || ! mfrc522.PICC_ReadCardSerial() ) {
delay(50);
return;
}
// Show UID on serial monitor
Serial.print("UID tag :");
String content= "";
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
content.concat(String(mfrc522.uid.uidByte[i], HEX));
}
Serial.println();
Serial.print("Message : ");
content.toUpperCase();
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Card UID:");
lcd.setCursor(0,1);
lcd.print(content.substring(1));
delay(1500);
}
Editor is loading...
Leave a Comment