Sorry for the wording of the question, I couldn't articulate it in such a short space.
I am developing a prototype board that utilises a LDR to set the backlight PWM value, so if the room is dark, so too is the LCD backlight. And if the room is bright, again, so too is the LCD. It works well.
I have a number of these boxes, and some have the LDR and some do not. Now I know that I could just code each box independently (a bit of a pain, but a #define could do the trick), alternatively, I could set an EEPROM value to indicate the presence of the LDR and code around that, although neither solution helps if the situation changes, ie a suitable LDR (via a grove connector) is plugged in or removed.
The LDR I am using is attached via a grove connector and I got it from Seeedstudio ( http://www.seeedstudio.com/depot/Grove-Light-Sensor-p-746.html ) so it has a resistor already in the connection.
But if the connector is removed the input floats, and it can do so quite substantially, causing the LCD backlight to constantly be changing. My immediate thought was to turn the pull up resistor on, but I've come to realise that this is counter productive because it's a pull-UP resistor and would in theory be across the LDR if it was present, so I would probably need a pull-down resistor. Alternatively (and now this is where I really show my electronics skills), I put the LDR between the analog pin and ground, and the resistor to 5v, and then have the pull up activated so that if on some boxes it's not present, then it's pulled high anyway (obviously I have to reverse my code regarding the reversal of LDR).
However, it hasn't quite gone as expected, and nor is it practical since the grove connectors are hard wired and unless I chop and change them, it's not going to happen.
So my next train of though revolves around having TWO resistors between the analog pin and ground. One that is a part of the grove connector, and one to pull the input low if there's nothing connected (and as I typed that I can already see that's not going to work since I need the pin to be pulled HIGH, not low).
Is there a resistor of suitable value I could put across the LDR that would allow it to function as required when it is present, that would also allow the circuit to function as desired when it's not?
As I said earlier, I can always incorporate a setting saved to eeprom to get around it, and it's easy enough to do, I just thought I would canvass this avenue first.
Thanks