A variable changes while i modify another one (it isn't even used in the function)

Getting interrupt handlers correct, even for experienced programmers, is difficult. Blink without delay is a much better choice for what you're doing.

You fail to protect the variable with a critical section.

Serial calls never belong in an interrupt service routine.

1 Like