Electronic – arduino – Unstable readings in photoresistor matrix with Arduino, OK with Ohmmeter – what’s wrong

arduinophotoresistorvoltage divider

I'm working on a photoresistor array with my arduino, and I'm having a little trouble getting stable readings.

I'm driving 7 rows one at a time with Arduino's digitalWrite(pin,HIGH) command and floating the other outputs with pinMode(pin,INPUT); Problem is, I got NO READING from my analogRead() voltage dividers unless the column is hooked up to my ohmmeter. Whats up with that?

Only the column connected to my ohmmeter outputs anything at all, all the other columns read zero. Whats in my ohmmeter that suddenly makes that sensor work?

Schematic with a LDR matrix

So if I connect my Ohm-meter to the positive rail of P1 and to MEGA Analog 0 (A0) connection, suddenly the whole column gets readings! Otherwise, zeros everywhere.

void readArray() 
  for(int i=0; i < ROWS; i++)
    for(int k=0; k<ROWS; k++)
      pinMode(rowPins[k], INPUT); 


    for(int j=0; j < COLS; j++) 
      holdVals[i][j] = analogRead(j); 


Best Answer

The answer JustJeff gave you is probably correct for why you only get something when the ohmmeter is connected. I'd like to address a different issue. That issue is that your photoresistor array isn't going to work.

The problem is that you cannot "turn on" a single row at a time. For example, lets say that you turn on the middle row. The top and bottom row lines are tri-stated from the uC. Current will go from the middle row line, through P5 to the left most column, through P1 to the top row line, through p2 to the next column line, and mess up your measurements for that column. Now imagine lots of "false paths" and you can probably work out that everything will get hopelessly messed up.

One solution to this is to put a schottky diode in series with every photoresistor (with the diode "pointed" to the column lines). You read a row just like you do now, although you might try driving the "unused rows" with a low signal instead of tri-stating them. I'm not sure if you'll have some wacky leakage current issues if you don't.

Even without the diodes, however, I would have expected you to read at least some voltage. Your low-side resistors (R in your schematics) might be too low of a value. Do like JustJeff said and measure the voltage on a column line. If it's close to zero then you have a hardware problem. If it's not close to zero then you have a software problem.

P.S., I didn't look at your C code, since I'm not familiar with programming on the Arduino.