Running motor for specified time

I want to run the motor for specified time and OFF automatically in a funtion
like :

if(anything=>0)
{

// I want the code for it here//

}

Suppose you have two buttons
One for Starting motor and other for stopping it.
Onclick event of “Start” button we are calling another function named as stopme().
This function will be executed after 3000 milliseconds.

button class=“btn-width-height” type=“button” onclick=“digitalMultiWrite([0,1],[HIGH,LOW]); setTimeout(stopme, 3000);” > Start;</button

button id="off_me"class=“btn-width-height” type=“button” onclick="digitalMultiWrite([0,1],[LOW,LOW]); "> STOP;</button

function stopme() {
document.getElementById(“off_me”).click();
}

1 Like

the best solution is to use the setTimeout function like this

// setTimeout(function, delay)

setTimeout(function() {
   setPinLow(9) // this function should be defined at a different place
}, 1000);

Here is an excellent Blog Post on using delays with Bolt http://tripent.net/2016/05/delay-in-javascript/

1 Like