I have been using a ldr to control a dc motor via arduino uno.
The problem is that i just want to run the dc motor for a specific amount of time (e.g. 6 seconds)
after the my ldr input has read "HIGH". It will be a great help if someone will teach me or help me.
for more infos about my project here's a link of my circuit. Thank you in advance to the community.
int ldr = 8;
int mot = 4;
void setup() {
pinMode(mot, OUTPUT);
pinMode(ldr, INPUT);
}
void loop(){
digitalWrite(mot, LOW);
if(digitalRead(ldr)==HIGH)
{
digitalWrite(mot, HIGH);
delay(1000);
}
}
sorry for the confusion. Currently my dc motor in my circuit runs continuously when the input in my ldr is high (when there is light). My goal is when my ldr reads high or when there is light the dc motor will only run for only 6 seconds and then stop.