Hi
Turning off the light shone on an LDR in a potential divider screws with my USB serial monitor.
I have a light dependant resistor (5K to 20M ohm) that I want to use as a qualitative sensor. I thought it would be perfectly good to have a potential divider from +5V to GND; the LDR between +5 and A0, and a 1.3M ohm resistor between A0 and GND. My program is basically the analog input example but printing to the serial monitor as well, and it requires an input from the serial to start.
The problem is, when I shine a bright light on the LDR, I receive the level '1023'... Then I turn the light off and then the trouble starts. It's quite tricky to pin down but the following is very repeatable;
Immediately serial connection is lost by my computer. (Serial port /dev/ttyUSB0 not found). Resetting the arduino doesn't seem to work, and neither does selecting /dev/ttyUSB1. I restart my computer and everything is fine.
I thought it might be shorting the arduino and resetting it but the LED keeps blinking, whereas when it is working properly and is reset the LED remains off whilst it waits for an input from the serial monitor. So either it isn't resetting, or is resetting and immediately receiving something through serial.
I tried with an additional 47K ohm resistor in series with the LDR. This lead to the range of values I could get being 820 (dark) to 860 (bright), rather than what I would expect; 62 (dark), 861 (bright) but that could just be some light leaking in. Again, turning the light off loses serial connection and mucks everything up again.
Using a different pin makes no difference, and removing the LDR from the circuit to just having a 47K / 1M3 potential divider leaves it sitting around 860 to 862 - as expected. Having a 1M3 / 1M3 potential divider leaves it going between 508 and 516 - as expected. Shorting the pin and +5 reads 1023 - as expected. And suddenly going from +5 to GND, GND to +5V and combinations of resistors all work as expected.
Anyone got any ideas what might be going to screw with the serial?
Thanks,
Andrew