Hello, I am trying to implement interactive table project using arduino MEGA. I am using IR sensor array to sense the hand or any object the store value in matrix and then switch in the corresponding LED's (in scanning mode.) My grid is of 8x8.

I will be sequentially scanning the IR sensor (8 sensors in coloumn at a time). I am planning to connect all the 8 IR to analog pins (from analog 0 to analog 7). But sampling frequency is 100us, and i cant waste so much time so i have lowered down the prescalar to 64, ie:- 60us sampling time.

i have something like this in my mind. matrix[m][n]=analogRead(0); matrix[m+1][n+1]=analogRead(1); matrix[m+2][n+2]=analogRead(2); matrix......=analogRead(3); matrix.....=analogRead(4); matrix.....=analogRead(5); matrix.....=analogRead(6); matrix.....=analogRead(7);

Ok, now here is my question. 1.) Can i do it like this and still get the right values? Will my uC wait for 8*60us to get the right values and then start executing the program? 2.) Any other suggestions?

I am planning to initialize a timer of 500us and then take values from respective ports.

How many IR sensors? 8 or 64?

Yes, analogRead() will wait the appropriate amount of time. You should test it. Some people have found that they need to do two reads in a row and throw away the first one.

How are shortening the analogRead() time? I'd go with an external ADC, can take a reading in 3 SPI transfers,12uS with SPI clock at 2 MHz. 12x64 = 768 uS. For example See section 6 Faster chips are also available.

i need to read all the 64 IR.
But to explain the time in my hand it goes like this…
I have 5ms to read all the 8 IR LED (after 5 ms next set of 8 IR will be read __ie:-25Hz refresh rate)
Now i have planned to use 0.5ms (500us) timer interrupt to sample IR values from sensors one by one in sequence, so that way i get values of all 8 sensors in 8*0.5ms=4ms (which is well with in 5ms time i have in hand)
i hope i i am explaining it right manner…please feel free to ask if any doubt.

So my questing is will that logic work or will i still get garbage values.
And i am really trying to reduce any ADC or any external hardware since i want to keep this as cheap as possible :-).

Thanks for your reply