To control LDR Sensor using Raspberry Pi Pico Board
Required Components
- LDR Sensor_1 no
- Raspberry Pi Pico board_1 no
- Connecting wires_1 set
Circuit
Steps
- Make sure the components are working properly.
- Connect the Raspberry Pi Pico GP27 pin to the LDR D0 pin.
- Connect the Raspberry Pi Pico 3V3 (OUT) pin to the LDR +5V pin.
- Connect the Raspberry Pi Pico GND to the LDR GND pin.
- Check the Python program.
- Check the Electrical circuit.
- Run the Python program.
Python Program
from machine import Pin
import time
ldr = machine.ADC(27)
while True:
print(ldr.read_u16())
time.sleep(2)