1

I'm a newcomer to Arduino, trying to read analog values from a circuit with a photoresistor. I believe I am using a 1-ohm resistor

The problem I am having is that my photoresistor does not seem to be working, or my circuit is wrong. When I run the below code on my Nano, my Serial monitor constantly prints 1023. When I cover the photoresistor completely with my finger, the value dips down to 900-950, but then jumps back up to 1023. It dips down to 900-950 again, and jumps back to 1023. This happens continuously.

Here is my code:

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  int value = analogRead(A0);
  Serial.println(value);
  delay(20);
}

Here is an image of the circuit I am using. In my case, I am using a Nano instead of Uno.

enter image description here

I ran the above code on the virtual circuit above, and it works as expected. However, on my physical device, the phenomenon I explained above occurs.

Is there something wrong with my circuit? Could it be an issue with my photoresistor?

  • 3
    the photoresistor is shorted ... please investigate how a breadboard is constructed – jsotola Oct 8 '20 at 20:46
  • Thanks for the reply. What does it mean for a photoresistor to be shorted? – CoolCapybara99 Oct 8 '20 at 20:56
  • 1
    Also, try a 10 kΩ resistor. – Edgar Bonet Oct 8 '20 at 20:57
  • Shorted means there is a flow from VCC (voltage, like +5V for Arduino) with no resistance to GND. This means a lot of current will flow, which might damage or at least make components not working the way they should. Check first how a breadboard works. – Michel Keijzers Oct 8 '20 at 21:27
  • shorted means that there is a conductor, such as a wire or breadboard bus, connected from one pin of the sensor to the other pin of the sensor ... this effectively removes the sensor from the circuit, because all of the current in the circuit will flow through the short, bypassing the sensor – jsotola Oct 8 '20 at 22:08
3

If you pealed the backing off the bread board you will find that you have plugged in your green, red and photo resistor wires into one piece of metal. This means they are shorted together and as such do not work as you might expect.

enter image description here

Also, be aware that photo resistor or cadmium sulfide cells are slow to react to changes in light. Sometimes taking about a second to fully change to a new resistance. If you need a faster response consider using a photo diode or photo transistor.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.