Using Multiple photo sensors on single board

Hello,
I want to install around 50 LDR sensors on Arduino Mega (which has 56 digital pins). Is it possible to read the high/low values of all the sensors simultaneously? or will it lag since I need the real time values.

Secondly I need to measure the time for which each sensor experiences high/low, will it be possible to calculate this time in real time on Arduino or would you recommend to read the values only from Arduino and do the processing on maybe Matlab?

Thanks in advance.

You ought to be able to read 56 inputs in no more than about five microseconds using direct port manipulation.

How fast do you need? You didn't specify.

TheMemberFormerlyKnownAsAWOL:
How fast do you need? You didn't specify.

Well, technically he didn't, but:

hammadn95:
LDR sensors

tells me "not very fast". Even with a digitalRead() call to each one individually you can read all of them ten times over in the time it takes for one to react to changing light. No need to do PORTx register reads in this case, though it does make it a LOT faster :slight_smile:

Thanks for the response.

Can you pls tell the time it will take for arduino to simultaneously perform the following process for each of the LDR sensor installed (total 56)

Calculate the time for which the LDR is low (light not striking)
Using that time value, calculate the distance using the simple speed/time formula

Secondly, do you think that a better sensor then LDR is available in the market to minimize the response time as much as possible? pls mention here.

Thanks :slight_smile:

hammadn95:
Can you pls tell the time it will take for arduino to simultaneously perform the following process for each of the LDR sensor installed (total 56)

Depends on your program, whether you do this with integer math or floating point math, what you do with the result, etc.

Secondly, do you think that a better sensor then LDR is available in the market to minimize the response time as much as possible? pls mention here.

Just about any common phototransistor is orders of magnitude faster than the LDR... photodiodes may be even faster.