Python Tutorials – Lesson 7 – LDR Sensor on Raspberry Pi Pico

To control LDR Sensor using Raspberry Pi Pico Board

Required Components

  1. LDR Sensor_1 no
  2. Raspberry Pi Pico board_1 no
  3. Connecting wires_1 set

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect the Raspberry Pi Pico GP27 pin to the LDR D0 pin.
  3. Connect the Raspberry Pi Pico 3V3 (OUT) pin to the LDR +5V pin.
  4. Connect the Raspberry Pi Pico GND to the LDR GND pin.
  5. Check the Python program.
  6. Check the Electrical circuit.
  7. 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)

Leave a Reply

Your email address will not be published. Required fields are marked *