0
LiquidCrystal\_I2C lcd(0x27,16,2);   
\#define sensorPin1 7  
\#define sensorPin2 8  
int enter=0;  
\#include <SPI.h>  
\#include <MFRC522.h>  
\#define exp\_buzz 3  
\#define SS\_PIN 10  
\#define RST\_PIN 9  
byte lock = 0;  
int rfidtap=0;  
MFRC522 rfid(SS\_PIN, RST\_PIN);  


int sensorState1 = 0;  
int sensorState2 = 0;  
int count=0;  
void setup()  
{  
 pinMode (sensorPin1, INPUT\_PULLUP);  
 pinMode (sensorPin2, INPUT\_PULLUP);  
 pinMode(4,OUTPUT);  
 pinMode(5,OUTPUT);  
 lcd.begin(16,2);  
 lcd.backlight();  
 lcd.setCursor(4,0);  
 lcd.print("COUNTER");  
 lcd.setCursor(0,1);  
 lcd.print("No Visitors    ");  
 delay(200);  
 Serial.begin(9600);  
 pinMode(exp\_buzz,OUTPUT);  
 SPI.begin();  
 rfid.PCD\_Init();  
}  
void loop()  
{    
  sensorState1 = digitalRead(sensorPin1);  
  sensorState2 = digitalRead(sensorPin2);  
 if(sensorState1 == 1){  
    count++;   
 digitalWrite(sensorPin2,LOW);  
 delay(1000);  
 digitalWrite(sensorPin2,HIGH);  
    enter++;  
   
  }  
 if(sensorState2 == 1){  
    count--;   
 digitalWrite(sensorPin1,LOW);  
 delay(1000);  
 digitalWrite(sensorPin1,HIGH);  
   
  }  
   
 if(count<=0)  
  {  
   
 lcd.setCursor(0,1);  
 lcd.print("No visitors    ");  
  }  
 else if (count>0 && count<10){  
   
 lcd.setCursor(0,1);  
 lcd.print("Visitors:   ");  
 lcd.setCursor(12,1);  
 lcd.print(count);  
 lcd.setCursor(13,1);  
 lcd.print("  ");   
   
  }  
 else {  
   
 lcd.setCursor(0,1);  
 lcd.print("Visitors:   ");  
 lcd.setCursor(12,1);  
 lcd.print(count);    
  }  
 if ( ! rfid.PICC\_IsNewCardPresent())  
 return;  
 if ( ! rfid.PICC\_ReadCardSerial())  
 return;  


  String ID = "";  
 for (byte i = 0; i < rfid.uid.size; i++) {  
 ID.concat(String(rfid.uid.uidByte\[i\] < 0x10 ? " 0" : " "));  
 ID.concat(String(rfid.uid.uidByte\[i\], HEX));  
 delay(300);  
  }  
 ID.toUpperCase();  
 if (ID.substring(1) == "23 83 A1 1D") {  
 delay(100);  
    rfidtap++;  
 Serial.println(rfidtap);  
   
 digitalWrite(exp\_buzz,LOW);  
   
   
  }  
 else {  
 digitalWrite(exp\_buzz,HIGH);  
 delay(1000);  
 digitalWrite(exp\_buzz,LOW);  
 delay(100);  
 digitalWrite(exp\_buzz,HIGH);  
 delay(1000);  
 digitalWrite(exp\_buzz,LOW);  
 delay(1000);  
   
  }  
if(enter > rfidtap) {  
 digitalWrite(4, HIGH);  
 digitalWrite(5, HIGH);  
 delay(8000);  
 digitalWrite(4, LOW);  
 digitalWrite(5, LOW);  
 delay(100);  
 Serial.println("beeeee");  
  enter = 0;  
  rfidtap = 0;  
}  


else{  
 digitalRead(enter);  
  }  


}  ```
when the value of enter is greater than rfid tap the commands under them does not work pls help fast
2
  • 3
    See how to ask a good question - please don't try to cram your question into the subject line. Make a brief subject and then explain what you expect to happen and what actually happens.
    – Nick Gammon
    Mar 16 at 5:46
  • 3
    What's with all the backslashes? Does this even compile?
    – Nick Gammon
    Mar 16 at 5:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.