Please Add Delay & Push Button Support

I need a button work temporarly with a delay,

                 Push   ---- ON for 200MS then auto turns off 

Setting up a trigger to turn it off works to some degree but it will delay randomly and for the amount of time it takes to turn off it could be 2 to 10 seconds which doens’t work very well.

Some people might want a switch that activates for a small window of time, maybe to open a garage door half way or soemthing that tight timimg is crutial. For myself I have a arduino program that i need a short button press for and cayenne just doesn’t cut it.

This can be done with user code on the Arduino or ESP, or with MQTT on the Raspberry Pi.

For Arduino, check out this post.

A pushbutton widget would be nice, but the functionality to turn off the momentary should always be controlled at the local level.

Cheers,

Craig

Couldn’t figure it so I ended up making a little bit of code on a Arduino nano to do it for me, here it is for anyne needing something, code is a little basic but it does the trick.

const int buttonPin = 2;
const int Pulse = 3;

int buttonState = 1;

void setup(){
Serial.begin(9600);
//Monitor Serial
pinMode(Pulse, OUTPUT);
pinMode(buttonPin, INPUT);
digitalWrite(buttonPin,HIGH);
}

void loop() {

while(a<10){
digitalWrite(2,HIGH);
delay(1000);
digitalWrite(2,LOW);
delay(1000);
}

buttonState = digitalRead(buttonPin);

  if(buttonState == LOW){
    delay(50);
    
  digitalWrite(Pulse, HIGH);
  delay(200);
  
  digitalWrite(Pulse,LOW);
  delay(200);

  }

}

1 Like