Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SPI.h>
- #include <MFRC522.h>
- #define SS_PIN1 8
- #define SS_PIN2 10
- #define RST_PIN 9
- MFRC522 mfrc522_1(SS_PIN1, RST_PIN); // Create MFRC522_1 instance.
- MFRC522 mfrc522_2(SS_PIN2, RST_PIN); // Create MFRC522_2 instance.
- int ledpin7 = 7;
- int ledpin5 = 5;
- char st[20];
- byte State = 0;
- void setup()
- {
- Serial.begin(9600);
- SPI.begin(); // Inicia SPI bus
- mfrc522_1.PCD_Init(); // Inicia MFRC522_1
- mfrc522_2.PCD_Init(); // Inicia MFRC522_2
- pinMode (ledpin7 , OUTPUT);
- pinMode (ledpin5 , OUTPUT);
- }
- void loop()
- {
- if( digitalRead(ledpin7) == HIGH )
- { Serial.println("y");
- delay(2000);
- }
- if( digitalRead(ledpin5) == HIGH )
- { Serial.println("k");
- delay(2000);
- }
- // Select one of the cards
- if ( ! mfrc522_1.PICC_ReadCardSerial())
- if ( ! mfrc522_2.PICC_ReadCardSerial())
- // Look for new cards
- if ( ! mfrc522_1.PICC_ReadCardSerial())
- {digitalWrite (ledpin7 , HIGH);
- }
- if ( ! mfrc522_2.PICC_ReadCardSerial())
- {
- // acende os leds
- digitalWrite (ledpin5 , HIGH);
- return ;
- }
- //Serial.print("UID da tag :");
- String conteudo_1= "";
- String conteudo_2= "";
- byte letra;
- for (byte i = 0; i < mfrc522_1.uid.size; i++)
- {
- //Serial.print(mfrc522_1.uid.uidByte[i] < 0x10 ? " 0" : " ");
- //Serial.print(mfrc522_1.uid.uidByte[i], HEX);
- conteudo_1.concat(String(mfrc522_1.uid.uidByte[i] < 0x10 ? " 0" : " "));
- conteudo_1.concat(String(mfrc522_1.uid.uidByte[i], HEX));
- }
- for (byte i = 0; i < mfrc522_2.uid.size; i++)
- {
- //Serial.print(mfrc522_2.uid.uidByte[i] < 0x10 ? " 0" : " ");
- //Serial.print(mfrc522_2.uid.uidByte[i], HEX);
- conteudo_2.concat(String(mfrc522_2.uid.uidByte[i] < 0x10 ? " 0" : " "));
- conteudo_2.concat(String(mfrc522_2.uid.uidByte[i], HEX));
- }
- conteudo_1.toUpperCase();
- conteudo_2.toUpperCase();
- if (conteudo_1.substring(1) == "E3 F5 31 DB") //UID Y - Chaveiro
- {
- digitalWrite (ledpin7 , LOW);
- //Serial.println("standby");
- }
- delay(200);
- if (conteudo_2.substring(1) == "53 0A 6D D9") //UID K - Chaveiro
- {
- digitalWrite (ledpin5 , LOW);
- //Serial.println("standby");
- }
- delay(200);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement