So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By uspinhal
#70693 Hi everyone!
I'm using a NodeMCU to control a solenoid through a relay. I need to stop this relay at any moment as na emergency stop, so I used the attachInterrupt function.
This is working and stopping the process at any time, but after 8 seconds the system restart and the process go on.
How can I fix this interrupt for a longer time then 8 seconds?

Someone could help me?

I'm using this function to interrupt:

Code: Select allvoid interrupt_back(){
 
  restart_buttom = LOW;
  lcd.setCursor(0,1);
  lcd.print("     PARADA    ");
 
  while (restart_buttom == LOW){
    restart_buttom = digitalRead(reset_pin);
    Serial.print("Status do botão: ");
    Serial.println(restart_buttom);
    Serial.println("Emergência Acionada");
   
  }

  lcd.print("                     ");
}
User avatar
By gdsports
#70763 Hardware interrupt functions must be very short. Typically less than 1 ms. I think digitalWrite and setting a flag are ok. In loop(), check the flag then do things like update the display, Serial.print, etc.
User avatar
By uspinhal
#70971
gdsports wrote:Hardware interrupt functions must be very short. Typically less than 1 ms. I think digitalWrite and setting a flag are ok. In loop(), check the flag then do things like update the display, Serial.print, etc.


Thanks buddy, this was the solution.