PLC guy needs abit of help with timers


hi guys,
i having few issues timers, there implementation, , understanding them. used industrial plc's , how there timers operate, struggling in big way arduino's.

what trying achieve once switch has been pressed 2 seconds led (for example) come on , stay on 5 seconds, 10 seconds later system reset self.

my problem lies in trying time initial switch pressing, have tried called "debounce timers" yet none seem work in way require. if point me in way of example epic  8) .

this @ :-
code: [select]
int sw1=12;
int value_1, value_2=0;
int led=13;
byte flag=0;
int i=0;
int a=0;

void setup()
{
    pinmode(sw1, input);
    digitalwrite(sw1, high);
    pinmode(led, output);
}

void loop()
{
    value_1=digitalread(sw1);

    if(!value_1)
    {
delay(50); 
value_2=digitalread(sw1);
if(!value_2)
{
    flag=1;
    do{
    }while(!digitalread(sw1));
}
    }

    if(flag==1)i++;
    if(i>3000)
    {
digitalwrite(led, high);
        delay (5000);
        digitalwrite(led, low);
        delay (1000);
while(1);
    }

    delay(1);
}



just incase need info have "franzis tutorial kit arduino" board looks uno, duemilanove atmega168 chip

i should add have had search, google'fu has let me down far


Arduino Forum > Using Arduino > Project Guidance > PLC guy needs abit of help with timers


arduino

Comments