mirror of
https://github.com/zzzzDev4/IAS-Better-Tea.git
synced 2025-04-21 07:31:20 +02:00
Extended RFID demo: display UID on OLED
This commit is contained in:
parent
04f49f8729
commit
c48d941334
1 changed files with 17 additions and 0 deletions
17
src/main.cpp
17
src/main.cpp
|
@ -30,6 +30,15 @@ void serial_dump_byte_array(byte *buffer, byte bufferSize);
|
|||
void printMsg(const String &s);
|
||||
void printMsg(unsigned long l);
|
||||
|
||||
void oled_dump_byte_array(byte *buffer, byte bufferSize)
|
||||
{
|
||||
for (byte i = 0; i < bufferSize; i++)
|
||||
{
|
||||
display.print(buffer[i] < 0x10 ? " 0" : " ");
|
||||
display.print(buffer[i], HEX);
|
||||
}
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
|
@ -105,8 +114,16 @@ void loop()
|
|||
// UID is a unique four hex pairs, e.g. E6 67 2A 12
|
||||
Serial.print(F("Card UID:"));
|
||||
serial_dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size);
|
||||
|
||||
display.clearDisplay();
|
||||
display.setTextColor(WHITE);
|
||||
display.setTextSize(1);
|
||||
display.setCursor(0, 10);
|
||||
display.println("Card UID: ");
|
||||
oled_dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size);
|
||||
display.println();
|
||||
display.display();
|
||||
|
||||
// PICC type, e.g. "MIFARE 1K0"
|
||||
Serial.print(F("PICC type: "));
|
||||
MFRC522::PICC_Type piccType = mfrc522.PICC_GetType(mfrc522.uid.sak);
|
||||
|
|
Loading…
Add table
Reference in a new issue