4- Night Light

Night Light Project

We learned how to control digital outputs using analog signals in the previous section. Now, for a more practical example, we will create a night light using analog signals. The project will be similar to the circuit used in street lighting.

For this project, we will use an LDR (Light Dependent Resistor). An LDR is a light-sensitive resistor that changes its resistance depending on the intensity of light. We will utilize these variations in resistance to detect changes in voltage. This will generate an analog signal for our circuit.

In summary, based on the amount of light, we will illuminate our LED. Due to the nature of the LDR, as the amount of light decreases, the analog signal will approach 1023. We will write our program using this information.

When connecting the LDR, we will connect one leg of the LDR to the A0 pin. We will connect the same leg to the Arduino’s 5V pin through a 10K resistor. The other leg of the LDR will be connected to the Arduino’s GND pin.

Codding:

We will run our LED if the digital value from the analog pin is greater than 750 in the following coding; otherwise, we will turn off our LED

Yorum bırakın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir

Scroll to Top