int ldrPin = A0;
int buzPin = 11;
int threshold = 500;
void setup() {
Serial.begin(9600);
}
void loop() {
int ldrValue = analogRead(ldrPin);
Serial.println(ldrValue);
if (ldrValue < threshold) {
tone(buzPin, 262, 1000);
} else {
noTone(buzPin);
}
delay(100);
}
Copyright ⓒ TECH79 All right reserved