Delay Function on Button

var dual1 =dualButton("center");
dual1.first_button({name:"ON", action:"digitalWrite", 
                  pin:"1", value:"HIGH", bgcolor:"green",
                  shape:"rectangle", text_color:"white"})

dual1.second_button({name:"OFF", action:"digitalWrite", 
                    pin:"1", value:"LOW", bgcolor:"green",
                    shape:"rectangle", text_color:"white"}) 

When the ON button is pressed PIN 1 should ON and OFF with a delay of 5min (loop)
When the OFF button is pressed PIN 1 should OFF

How to do it?

Hi @pavanesleeba,

You can not add timeout function in Dualbutton class, but you can write your javascript function to do that.

add the code below:

button = document.createElement("BUTTON");
button.classList.add("btn");
var text = document.createTextNode("On");
button.appendChild(text);

button.onclick = function() {
    digitalWrite(1, 'HIGH');
    setTimeout(() => {
        digitalWrite(1, 'LOW');
        
    }, 30000);
    
};

document.body.appendChild(button); 

Do let me know in case you need further assistance.