LDR Light Sensor on Raspberry Pi Pico
by cryp7o in Circuits > Raspberry Pi
2410 Views, 2 Favorites, 0 Comments
LDR Light Sensor on Raspberry Pi Pico
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
– 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
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)