How can i record time intervals from 5 different ir sensors

Hello I currently have a problem with my project. The idea was that i will have 5 different IR sensors set up in my model track to measure the velocity and the acceleration of the object in my track. My approach to my problem was using the attachInterrupt function and so it will start time count millis() if the sensor senses something. So far so good. Using the millis() for start and millis() for ends. Now when i was retrieving the time data. It seems that the only time recorded was from sensor 1 and sensor 2. I can't get/access the time from 3,4 and 5. My code is fine, i guess i just misunderstood on how to use the millis() function. Can i use it multiple times? I don't know what to do. Any help would be greatly appreciated.

It is a bit hard to help without any code (Note: Ide has a function to format code for the forum).

millis() can be uses as many times as you wish, every time it return how many milliseconds there has passed from reset. If you use Timer 0 or disable interrupt for more than 1 millisecond it will not give correct values.
Using attach interrupt can disable interrupt if you do it wrongly. The routine must be short and not wait for anything.

Of you're using a 328P based board (e.g. Uno), you can only attach two interrupts (pins 2 and 3).

Post a schematic (photo of hand drawn is fine), post your code.

My code is fine

Nop.

If you are timing in milliseconds you should not be using interrupts!

Let's assume your bug is in row 42.

If this doesn't help, read this .

If this still doesn't help, answer all bullets from No. 11.

If "you're using a 328P based board (e.g. Uno), you can only attach two interrupts (pins 2 and 3)."

True for hardware interrupts. All the other pins can also be used PCINTs.

I would time in microSeconds. 1000uS in a mS.

"mS" is not a millisecond! Likewise "┬ÁS". :roll_eyes: