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 Arduino program.
- Check the Electrical circuit.
- 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");
}
}