hello i has question that maybe someone could help with
i have this code
int ledPin = 3; // choose the pin for the LED
int inputPin = 9; // choose the input pin (for PIR sensor)
int photoPin = A0; // choose the input pin (for photoresistor)
int pirState = LOW; // we start, assuming no motion detected
int val = 0; // variable for reading the photoresistor value
void setup() {
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inputPin, INPUT); // declare sensor as input
pinMode(photoPin, INPUT); // declare photoresistor as input
Serial.begin(9600);
}
void loop(){
val = analogRead(photoPin); // read the value from the sensor
Serial.println(val);
if (val > 500) { // if it's bright turn off the LED
digitalWrite(ledPin, LOW);
delay(10);
}
if (digitalRead(inputPin) == HIGH) { // check if the PIR sensor is triggered
if (pirState == LOW) {
Serial.println("Motion detected!");
pirState = HIGH;
digitalWrite(ledPin, HIGH);
delay(10);
}
} else {
digitalWrite(ledPin, LOW);
pirState = LOW;
}
}
and would like to keep the LED off when the photo sensor sees light
no mader if the motion is detected