int count = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(11, INPUT);
pinMode(2, INPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println("Total Passengers = ");
Serial.println(count);
delay(100);
if(digitalRead(11) == HIGH){
count++;
}
else {
count = count;
}
if(digitalRead(2) == HIGH){
count--;
}
else{
count = count;
}
if(count > 10){
digitalWrite(3, HIGH);
Serial.println("Warning! Limit Exceeded!");
digitalWrite(4, LOW);
}
else{
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
count = count;
}
}