VISITOR COUNTERS USING BUTTONS int VisitorCounter=0;
int buttonState=0;
int lastButtonState=0;
void setup()
{
pinMode(3,INPUT_PULLUP);
pinMode(29,OUTPUT);
pinMode(10,OUTPUT);
Serial.begin(9600);
}
void loop()
{
buttonState=digitalRead(3);
if(buttonState!=lastButtonState)
{
if(buttonState==HIGH)
{
VisitorCounter++;
digitalWrite(10,HIGH);
Serial.println("Visitor IN");
Serial.print("VisitorCounter :");
Serial.println(VisitorCounter);
delay(1);
}
else
{
digitalWrite(10,LOW);
}
}
lastButtonState=buttonState;
if(VisitorCounter ==100)
{
Serial.print("100 Visitors Reached :");
Serial.print("Housefull");
delay(1000);
digitalWrite(29,HIGH);
}
else
{
digitalWrite(29,LOW);
delay(1000);
}
}