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>
- #include <LiquidCrystal.h>
- #include <SD.h>
- // Pino ligado ao CS do modulo
- #define chipSelect_SD A3;
- #define SS_PIN A5
- #define RST_PIN A1
- MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
- LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
- char st[20];
- void setup()
- {
- SPI.begin(); // Inicia SPI bus
- mfrc522.PCD_Init(); // Inicia MFRC522
- //Define o nΓΊmero de colunas e linhas do LCD:
- lcd.begin(16, 2);
- SD.begin(chipSelect_SD);
- mensageminicial();
- }
- String last_ID = "";
- 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
- String conteudo= "";
- byte letra;
- for (byte i = 0; i < mfrc522.uid.size; i++)
- {
- conteudo.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
- conteudo.concat(String(mfrc522.uid.uidByte[i], HEX));
- }
- conteudo.toUpperCase();
- lcd.setCursor(0, 1);
- if(conteudo.substring(1) != last_ID){
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("Ant. ");
- lcd.print(last_ID);
- lcd.setCursor(0,1);
- lcd.print(conteudo.substring(1));
- last_ID = conteudo.substring(1);
- }
- delay(200);
- }
- void mensageminicial()
- {
- lcd.clear();
- lcd.print(" Aproxime o seu");
- lcd.setCursor(0,1);
- lcd.print("cartao do leitor");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement