BI-DIRECTIONAL PEOPLE SENSOR AND COUNTER USING ARDUINO BOARD

Well for starters to count you could do this.

my_ISR () {

   // we got here because S1 was activated (and debounced in hardware)
   count += digitalRead(S2) == HIGH ? 1 : -1;

}

An interrupt is not really required here but IMO makes life easier as long as the input signal is clean.


Rob