Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // --- Bibliotecas Auxiliares ---
- #include <SPI.h>
- #include <MFRC522.h>
- // --- Mapeamento de Hardware ---
- #define SS_PIN 8
- #define RST_PIN 9
- MFRC522 mfrc522(SS_PIN, RST_PIN); // Cria instância com MFRC522
- // --- Variáveis Globais ---
- char st[20];
- // --- Configurações Iniciais ---
- void setup()
- {
- Serial.begin(9600); // Inicia comunicação Serial em 9600 baud rate
- SPI.begin(); // Inicia comunicação SPI bus
- mfrc522.PCD_Init(); // Inicia MFRC522
- //Serial.println("x");
- Serial.println();
- } //end setup
- // --- Loop Infinito ---
- void loop()
- {
- // Verifica novos cartões
- if ( ! mfrc522.PICC_IsNewCardPresent())
- {
- return;
- }
- // Seleciona um dos cartões
- if ( ! mfrc522.PICC_ReadCardSerial())
- {
- return;
- }
- // Mostra UID na serial
- //Serial.print("UID da tag :");
- String conteudo= "";
- byte letra;
- for (byte i = 0; i < mfrc522.uid.size; i++)
- {
- //Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
- //Serial.print(mfrc522.uid.uidByte[i], HEX);
- conteudo.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
- conteudo.concat(String(mfrc522.uid.uidByte[i], HEX));
- }
- Serial.println();
- //Serial.print("Mensagem : ");
- conteudo.toUpperCase();
- if (conteudo.substring(1) == "E3 F5 31 DB") //UID 1 - Chaveiro
- {
- Serial.println("boneca");
- Serial.println();
- delay(1000);
- }
- if (conteudo.substring(1) == "53 0A 6D D9") //UID 2 - Cartao
- {
- Serial.println("Bola");
- Serial.println();
- delay(1000);
- }
- if (conteudo.substring(1) == "F3 63 4C E5") //UID 2 - Cartao
- {
- Serial.println("carro");
- Serial.println();
- delay(1000);
- }
- } //end loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement