LDR Light Sensor on Raspberry Pi Pico
by cryp7o in Circuits > Raspberry Pi
1614 Views, 2 Favorites, 0 Comments
LDR Light Sensor on Raspberry Pi Pico
![Presentation1.gif](/proxy/?url=https://content.instructables.com/FXY/UECH/LN1RB3RN/FXYUECHLN1RB3RN.gif&filename=Presentation1.gif)
a light sensor, also known as LDR (Light-Dependant Resistor) or photo-resistor, connected to a Raspberry Pi Pico. to measure the intensity of the ambient light.
Supplies
Princple
A photoresistor is a passive component that decreases resistance with respect to receiving luminosity on the component's sensitive surface. The resistance of a photoresistor decreases with an increase in incident light intensity;
Schematic Diagram
![Screenshot 2023-09-27 165154.png](/proxy/?url=https://content.instructables.com/FZY/R6OT/LN1RB6HU/FZYR6OTLN1RB6HU.png&filename=Screenshot 2023-09-27 165154.png)
![Screenshot 2023-09-27 165809.png](/proxy/?url=https://content.instructables.com/F4T/P4WY/LN1RB6HV/F4TP4WYLN1RB6HV.png&filename=Screenshot 2023-09-27 165809.png)
– connect one end of the LDR to GP27 (=GPIO 27 or ADC1)(orange)
– connect the other end of the LDR to a GND (ground) pin(blue)
Source Code
![Screenshot 2023-09-27 165154.png](/proxy/?url=https://content.instructables.com/FBL/UBSV/LN1RB6M9/FBLUBSVLN1RB6M9.png&filename=Screenshot 2023-09-27 165154.png)
from machine import Pin
import time
ldr = machine.ADC(27) # Initialize an ADC object for pin 27
while True:
ldr_value = ldr.read_u16() # Read the LDR value and convert it to a 16-bit unsigned integer
print("LDR Value:", ldr_value) # Print the LDR value to the console
time.sleep(2)