need help in arduino, on delay button.

0

Recently i face a problem on my elevator project.

when i press my button it show’s high but after i release it is low

how to delay my button as high for 5 sec ?

 

i did try with this program, lets said

 

const int button = 2; //declare button in pin 2

const int motorup = 8;

const int motordown = 9;

 

void setup() {

pinMode (button,INPUT);

pinMode (motorup,OUTPUT);

pinMode (motordown,OUTPUT);

 

}

 

void loop(){

buttonState = digitalread(button);

if (buttonState == HIGH){

digitalwrite(motorup,HIGH);

delay(5000);

}

 

but the delay of 5 sec might effect my other program below, how to make the switch on only for 5 sec without interrupt the other program below?

 

 

Thanks in advance.

 

 

 

 

asked August 24, 2015

Your Answer