Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By schufti
#74620 what you are seeing and treating is only the symptom. the cause is that your button is not debounced, thus your interrupt routine is called several times during first 5-10ms of keypress. During this time the isr (or other part) is still in serial.println() which itself is using interrupts, asking for trouble on systems with limited interrupt / stack capabilities like esp8266 (It is not like avr µC where you could disable or prioritize interrupts for ease of game).

a) in isr: only set flags, never use delay()
b) isr belongs to ICACHE_RAM
void ICACHE_RAM_ATTR isr(void)
c) keys need debounce
User avatar
By skettlitz
#74691 You should mark your ISR with ICACHE_RAM_ATTR and do not call any function that is not marked this way. Calling library functions is probably unsafe. It works a few times when the code is in the CPU cache and then it fails randomly.

You could probably use the os timer functions which have less restrictions instead or place your code in the loop function.