I am in need of help to use a routine asynchronous to the program, that in a certain programmed time it will be activated independent of the rest of the program. In my program there are stops for verification, and when I need to make a start there is a delay for this verification until an output goes to HIGH. And I would like my activation to be within this asynchronous routine so that the output goes to HIGH immediately. I really appreciate anyone who can help. My code is attached
Estou precisando de ajuda para usar uma rotina assincrona ao programa, que em determinado tempo programado ela seja ativada independente do resto do programa. No meu programa existem paradas para verificação, e quando eu preciso realizar um acionamento há um delay por essa verificação até uma saída ir para HIGH. E eu gostaria que meu acionamento estivesse dentro dessa rotina assincrona para que a saída vá para HIGH de imediato. Agradeço muito quem puder ajudar. Meu codigo está anexado
Meu codigo.txt (12.3 KB)
Hello and and welcome.
Before you do anything else please take a moment to read General guidance and
How to use this forum
Especially item #7 on posting code.
I guess English is not your first language. Based on what I think you mean and not having looked at your code I think you need to read and understand the following:
Using millis for timing
Demonstration for several things at the same time
I hope that helps.
And I would like my activation to be within this asynchronous routine so that the output goes to HIGH immediately.
the title of the thread suggests you think you need an interrupt.
when you say immediate, how quick: with 1 usec, 1msec, 1sec?
you also say asynchronous route. what else does you code need to do?
looks like you code will loop to process as many pending mqtt message as there are. why not check for an process at most 1 mqtt message per iteration of loop()?
I need an interruption, but I don't know how to do it. In my loop routine, the program subscribes to a server every 5 seconds, if I decrease this time the server does not respond to me. I need that, for example, when I activate a digital input, an output goes up immediately, with a maximum of 1 second delay.
I need that, for example, when I activate a digital input, an output goes up immediately, with a maximum of 1 second delay.
You don't need an interrupt if you need a response in no more than 1 second. You can respond well within that timeframe using polling.
This 5 second subscribe that is inside the void loop, cannot be less than 5 seconds because the server stops responding to me.