#define LDR_PIN 34
#define BUZZER_PIN 14
#define LED_PIN 26
const int threshold = 2000;
void setup() {
pinMode(LDR_PIN, INPUT);
pinMode(BUZZER_PIN, OUTPUT);
pinMode(LED_PIN, OUTPUT);
Serial.begin(115200);
}
void loop() {
int ldrValue = analogRead(LDR_PIN);
Serial.println(ldrValue);
if (ldrValue < threshold) {
tone(BUZZER_PIN, 262, 250);
digitalWrite(LED_PIN, HIGH);
} else {
noTone(BUZZER_PIN);
digitalWrite(LED_PIN, LOW);
}
delay(10);
}