Hi Leto,
Just some things to consider:
It sounds like you want to understand the direction of the motion. Have I understood?
The advice Ian gave you is good, and you should follow it. I think it is all you need, really, but if the above is true, then you will also need some kind of clock.
With each of the 12 inputs -
Test the input if it is low go to the next
if it is high time stamp and record which input
then, I would have an interrupt each second to analize the total count.
You could also increment a timer in this interrupt, but don't let your interrupt get too long, or you will lose any inputs! I think you could just do the analysis outside of the loop which tests if any inputs are high.
read_portb(); // read 12 bits simultaneously
The micros I know have only 8 bits per port, but yes, you could read the ports, two of them, one at a time. Anything more than 0x00 would indicate a tripped sensor; you wouldn't have to walk an array, and then write to another one. You would know which pin from the hex number you read on the port.
Is posible to include some IC in order to have "latched" each input and like this to avoid to lose some event?
Well you could latch them, but why would you want to? The controller is fast enough to get all 12 and process them, and do it all over so many times a second it would make your head spin. You won't miss any.
Something else you may want to look at is noise. You didn't say how far away the sensors are, but there is a good chance in the real world, of false triggers and other noise. Perhaps some scheme similar to switch debouncing would work here. I mean if one sensor is tripped only once for a time of a micro second or so, and no others are tripped it is probably a false signal. I would think that most moving objects would not be that fast, but then I don't know just what you are doing. More information would stimulate more ideas.
Anyway, your project is interesting; please keep us abreast of your developments.
Regards,
Robert