Echo & Alexa Forums

How to switch on, delay,then switch off a device

0 Members and 1 Guest are viewing this topic.

mpeill

How to switch on, delay,then switch off a device
« on: June 08, 2021, 09:22:41 am »
I have a device acting as a simple switch. I can use Alexa to switch it on, and also to switch it off.
I want a single command to ask Alexa to switch it on, leave it on for 2 seconds, then switch it off. (without the need to issue an "off" command).
Alexa would then be ready to receive the same "switch on" command to perform the same result at a later date.
Anyone know whether this is possible?

mpeill

Re: How to switch on, delay,then switch off a device
« Reply #1 on: June 08, 2021, 11:09:45 am »
Ah, solved it. I was using the "delay" function and find there is an issue with this in the Arduino IDE (see other posts/forums). I've used a "while" loop and millis() and it works fine now.