Hi i am currently doing my final year bachelors project and building a automated streetlight And i want to know the amount of time the Led stays on after the motion sensor is triggered, Searched many places tried codes but couldnt do it. Would be great if someone can help me
Here is my code for which i want to know the amount of time LED is on
I tried to use pulseIn but couldnt figure it out. Plus i am a beginner.
int LED = 13;
int PIR = 7;
void setup() {
Serial.begin(9600);
pinMode(LED,OUTPUT); //gives output according to pir sensor
pinMode(PIR,INPUT); // takes input ie motion
}
void loop() {
int value = digitalRead(PIR);
if (value == 1){
digitalWrite(LED, HIGH);
}
else {
digitalWrite(LED, LOW);
Serial.println("NO motion");
}