Well if we look back at the simple people counter we really have two signals. We have a clock pulse and we have a logic level that tells us up or down. A few sensors and gates do the decision making. So let's say we have a PIC out there rather than a counter chip. The front end of the circuit doesn't know or care what is out there. It works independently. So lets say we run our count up or down signal to out pic on a digital input line. Now we know as drawn that if that line is logic low and a clock pulse is received we want the counter to increment up a count and if the logic is low we want to decrement the count. So we have let's say N is the count. Therefore a pulse for count will be either N plus 1 or N minus 1. Logically since we need to start with an empty room or store that N would equal 0. At this point it is just a matter of writing the code for your PIC. IF a line is low and a pulse comes along on another digital in THEN ... I am sure you get the idea. Remember in my posted circuit (which is a common logic circuit) forget the counter chip and look at the two signals from the front end that make it work.
I won't do the work or write the code samples. However, I will keep pointing.
Ron