Arduino Tutorials – Lesson 42 – 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 Arduino program.
  6. Check the Electrical circuit.
  7. Run the Arduino program.

Arduino Program

const int ledPin=25;
const int ldrPin=27;

void setup(  )
{
  Serial.begin(9600);
  pinMode (ledPin,OUTPUT);
  pinMode (ldrPin,INPUT);
}

void loop( )
{
  int ldrstatus = analogRead(ldrPin);
  if (ldrstatus<=300)
 {
    digitalWrite(ledPin,HIGH);
    Serial.print("LDR in Dark,LED is ON");
  }
  else
  {
    digitalWrite(ledPin,LOW);
    Serial.print ("LDR in Light,LED Is Off");
  }
}

Leave a Reply

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