#define LDR_PIN 26
#define PIR_PIN 16
#define LED_PIN 15
int lightThreshold = 2000; // подбирай (0–4095)
void setup() {
pinMode(PIR_PIN, INPUT);
pinMode(LED_PIN, OUTPUT);
Serial.begin(115200);
}
void loop() {
int lightValue = analogRead(LDR_PIN);
int motion = digitalRead(PIR_PIN);
Serial.print("Light: ");
Serial.print(lightValue);
Serial.print(" | Motion: ");
Serial.println(motion);
if (lightValue < lightThreshold && motion == HIGH) {
digitalWrite(LED_PIN, HIGH);
} else {
digitalWrite(LED_PIN, LOW);
}
delay(200);
}Loading
pi-pico-w
pi-pico-w