TIMER LOGIC

#include <elapsedMillis.h>

elapsedMillis timeElapsed;

unsigned int interval = 10000;

void setup() {
pinMode(2,INPUT_PULLUP);
pinMode(3,INPUT_PULLUP);
pinMode(13,OUTPUT);
pinMode(4,OUTPUT);
}
void loop() {
if(digitalRead(2)==LOW){
digitalWrite(13,HIGH);

}
else{
digitalWrite(13,LOW);
}
digitalWrite(4,HIGH);
digitalRead(3);
elapsedMillis timeElapsed;

if (timeElapsed > interval && digitalRead(3)==HIGH) {
digitalWrite(4,LOW);
}
else {
digitalWrite(4,HIGH);

}
}
I want pin4 should go LOW if pin 3 do not get true within stipulated interval. if pin 3 get true before stipulated interval then pin 4 should remain high.If pin 3 get true within stipulated time but if again it go false then after stipulated interval pin 4 should go LOW. Anybody of ARDUINO FAMILY will help me.
N.N.Joglekar from M/S JOGLEKAR SONS.

Put EVERY { on a line BY ITSELF.
Put EVERY } on a line BY ITSELF.

Use Tools + Auto Format.

Post your code again, using code tags, as explained in the stickies at the top of the forum, the ones that you were supposed to read BEFORE you blundered in here.

Then, explain why you bother calling digitalRead() to read pin 3, but throw away the result.

Explain why you create another instance of elapsedMillis in loop(). Explain why you are comparing the instance to 10000.

Finally, explain why you think you need to use a class instance to accomplish such a simple task.

nnjoglekar:
within stipulated interval.

An interval needs a beginning: what triggers the start of this interval?

Maybe have a look at how millis() is used to manage timing without needing any library in several things at a time

...R