Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Programa : RFID - Controle de Acesso leitor RFID
- //Autor : FILIPEFLOP
- #include <SPI.h>
- #include <MFRC522.h>
- #define SS_PIN 10
- #define RST_PIN 9
- MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
- char st[20];
- void setup()
- {
- Serial.begin(9600);
- SPI.begin(); // Inicia SPI bus
- mfrc522.PCD_Init(); // Inicia MFRC522
- Serial.println("Aproxime o seu cartao do leitor...");
- Serial.println();
- //Define o número de colunas e linhas do LCD:
- mensageminicial();
- }
- void loop()
- {
- // Look for new cards
- if ( ! mfrc522.PICC_IsNewCardPresent())
- {
- return;
- }
- // Select one of the cards
- 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) == "ED 78 03 CA") //UID 1 - Chaveiro
- {
- Serial.println("Ola FILIPEFLOP !");
- Serial.println();
- delay(3000);
- mensageminicial();
- }
- if (conteudo.substring(1) == "BD 9B 06 7D") //UID 2 - Cartao
- {
- Serial.println("Ola Cartao !");
- Serial.println();
- delay(3000);
- mensageminicial();
- }
- }
- void mensageminicial()
- {
- Serial.println();
- Serial.print("Aproxime seu cartão");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement