#define buttonUP 8 // the number of the pushbutton pin #define buttonDOWN 7 // the number of the pushbutton pin #define Enable 4 #define Motor1 5 #define Motor2 6 float PressTime; void setup() { Serial.begin(9600); // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); // initialize the pushbutton pin as an input: pinMode(buttonUP, INPUT); pinMode(buttonDOWN, INPUT); pinMode(Enable, OUTPUT); pinMode(Motor1, OUTPUT); pinMode(Motor2, OUTPUT); } void loop() { if (digitalRead(buttonDOWN) == HIGH) { PressTime = pulseIn(buttonDOWN, LOW); //defalt wait time 1 sec Serial.println(PressTime); digitalWrite(Enable, HIGH); digitalWrite(Motor1, HIGH); digitalWrite(Motor2, LOW); if (PressTime > 1000) { delay(50000); //approx time for desk to move fully in one direction } } else if ((digitalRead(buttonUP) == HIGH)) { PressTime = pulseIn(buttonUP, LOW); //defalt wait time 1 sec Serial.println(PressTime); digitalWrite(Enable, HIGH); digitalWrite(Motor1, LOW); digitalWrite(Motor2, HIGH); if (PressTime > 1000) { delay(50000); } } else { digitalWrite(Enable, LOW); } }