Arduino Advent Calendar Day 19 - Laser Module

Need help for the Arduino Advent Calendar Day 19 Guide? Just post on this thread and our highly trained team of Arduino ninjas will be able to help you in no time!

At first, this just made the buzzer buzz all the time. Then I switched the 10 ohm resistor for the 220 ohm, this then made it buzz when the laser was shone on it and cut off when it was not. Then I changed the line
if (ldr_value < 600) { to
if (ldr_value>600) { and now it works as it should, that is it is quiet when the laser shines on the LDR and makes a 3 second buzz when interrupted. Am I right or crazy?

@johnrobinson, play around with the 600 value to one that works for the brightness levels of your environment!

I changed it up and changed it down, nothing worked except what I said above. If the light decreases when you break the beam the LDR resistance should increase so should not your code line be as I have it > not less than as in the code? Or am I wrong?


Are you sure you used a 10 ohm resistor? The instructions said to use a 10k ohm resistor, which is a thousand times different. I don’t know the minimum resistance of the LDR, but if it is particularly low in bright light, a 10 ohm resistor may have allowed too much current to flow and the LDR would be damaged.

However, the LDR would not usually respond to damage by reversing the light vs resistance curve.

Using a 220 ohm resistor is also a bit of a risk, because higher than specified current may flow in bright light, which if it happens for a long time in a hot environment may heat the LDR to damage.

Please switch back to using a 10k ohm resistor.

Also, check that you have attached the other end of the 10k ohm resistor to 5V, and the other end of the LDR to GND. What you observe would happen if you got those reversed.

Yes, if you got those wires reversed, changing from < to > in the code would cover for the mistake.

I agree with @team, the value 600 is the best place to tune, and is dependent on how bright the environment is where you are testing. You can use the serial monitor to find out what values are being measured.

Hope that helps!