void setup()
{
Serial.begin(9600);
SPI.begin();
mfrc522.PCD_Init();
Serial.println("Approximate your card to the reader...");
Serial.println();
pinMode (6, OUTPUT);
pinMode (7, OUTPUT);
digitalWrite(7,LOW);
digitalWrite(6, LOW);
}
void loop()
{
String content= "";
// Scan for cards
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Selects a card
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
//show UID on serial monitor
Serial.print("UID tag :");
for (byte i = 0; i < mfrc522.uid.size; i++)
{
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
content.concat(String(mfrc522.uid.uidByte[i], HEX));
}
Serial.println();
Serial.print("Message : ");
content.toUpperCase();
if ((content.substring(1) == "30 89 14 1C") ) //change the codes with the cards codes found after scanning in serial monitor
{
Serial.println("Authorized access");
Serial.println();
digitalWrite (7,HIGH);
delay(3000);
digitalWrite (7,LOW);
delay(3000);
}
else {
Serial.println(" Access denied");
digitalWrite (6,HIGH);
delay(3000);
digitalWrite (6, LOW);
delay(3000);
}
}
const int TRIG_PIN = 4; // Arduino pin connected to Ultrasonic Sensor's TRIG pin
const int ECHO_PIN = 2; // Arduino pin connected to Ultrasonic Sensor's ECHO pin
const int LED_PIN = 3; // Arduino pin connected to LED's pin
const int DISTANCE_THRESHOLD = 15; // centimeters
// variables will change:
float duration_us, distance_cm;
void setup() {
Serial.begin (9600); // initialize serial port
pinMode(TRIG_PIN, OUTPUT); // set arduino pin to output mode
pinMode(ECHO_PIN, INPUT); // set arduino pin to input mode
pinMode(LED_PIN, OUTPUT); // set arduino pin to output mode
}