I'm working on a project that counts the number of cars that parks in the parking lot and the number of vacant and occupied space within a certain time. Placing the sensors on the top of parking space to detect if it's vacant or occupied at the same time it counts how many were detected. For my prototype, I'm using only 2 ir sensors.
I'm having trouble in may the algorithm and some syntax because I'm a newbie in arduino.
anyone can help me with this? please?
thanks a lot.
int pin=4;
int counter=0;
int detected=false;
void setup() {
Serial.begin(9600);
pinMode(pin,INPUT);
}
void loop(){
}
void count() {
int val=digitalRead(pin);
if( (val == 0) && (detected == false ) ){
++counter;
detected = true;
delay(2000);
Serial.print("Occupied =");
Serial.println(counter);
}
else if( (val == 1) && (detected == true ) ){
counter==counter;
delay(2000);
detected = false;
Serial.println(counter);
Serial.print("Vacant=");
}
}