How do I make arduino to check for particular pins( namely 5 pins) whether it is high or low for 10 seconds, because interrupts check for the changes all the time? I suppose I will not be able to use interrupts and I need to check the particular pins only for 10 seconds then it should go off?
void loop()
{
int a = digitalRead(2);
int b = digitalRead(3);
int c = digitalRead(4);
int d = digitalRead(5);
int e = digitalRead(6);
if(a ==1)
{
//do something
}
if(b == 1)
{
// do something
}
....
this process should be checked by processor only for 10 seconds and after that it should not check.. How do I do it?
You need to specify the action more precisely Do you mean.
Check for all 5 buttons remain active simultaneously for the entire 10 second time frame
Check for all 5 buttons become active simultaneously at some point within a given 10 second time frame
Check that each of the 5 buttons become active at least once within the 10 second time frame
Also is this 10 second time frame at the start or is it ANY 10 second time frame while the sketch is running?
Check for all 5 buttons remain active simultaneously for the entire 10 second time frame, and it starts from the start and even in the middle of the execution
Start a timer when all 5 pins are first active at the same time.
If the time (10 secs) expires do whatever you want
If during the 10secs any of the pins goes inactive, stop the timer
(or reset the timer - in which case it will automatically start the countdown again when all pins are active)
If you haven't already seen it look at the demo several things at a time for an illustration of how to use millis() for the timing.