I am proposing to use a Mega 2560 to detect when a number of LDRs are in shadow. In my initial tests I was not using pins 20 and 21 (which are also SDA and SCL) and everything is working fine. I have a 220k resistor connected to VCC and to the LDR and the other end of the LDR connected to GND. When the light falls on the LDR it registers LOW at the junction between it and the resistor. When it is in shadow it registers HIGH.
But when I connected two LDRs to pins 20 and 21 they registered "dark" unless I shone a very bright light on the LDR. It is behaving as if those pins present a very low impedance.
I have tried both a genuine Mega and a clone with the same result.
Normally for detecting the LDRs I have the I/O pin set as INPUT but it made no difference to pins 20 and 21 when I applied INPUT_PULLUP.
I have not been able to find anything in the Atmega datasheet to suggest that those pins behave differently from any other I/O pin.
It is a real PITA if I can't use those pins because I had a very convenient pin allocation worked out - I have about 20 LDRs to work with.
Is anyone aware of any reason for this behaviour or a workaround?
...R