11/16/2023 0 Comments Arduino delay statements in interruptsWhy doesn’t this happen with the ISR trigger set to FALLING? Is the amount of interrupts disturbing the timing of the main loop delay?Ģ) if the program keeps executing the ISR but returns to the main loop every time in between, I would expect the millis() to be updated every time. This way it looks to me that the program returns to the main loop, but the delay time is wrong, so it doesn’t return to the right place, or the timing is not correct anymore. If the sensor is activated for a couple of seconds:ġ) if the program keeps running the ISR, I would not expect activity from the red led (main loop), but that led is blinking, with delay of about 2 seconds (without the interrupt that should be 5 seconds). What happens if the ISR has been executed once? Does the program return to the main loop to the place where the interrupt was initiated and then right back to the ISR, or does it stay in the ISR without getting back to the mainloop for as long as the signal stays LOW? If the sensor is activated and the signal on interrupt pin 3 is LOW, sensorOn will be executed. Static unsigned long lastInterruptTime=0 ĭigitalWrite(ledPinGreen,ledGreenStatus) int sensorPin3=3 ĪttachInterrupt(digitalPinToInterrupt(sensorPin3), sensorOn, LOW) The question is what goes wrong, and why, when the ISR trigger is set to LOW. The red led in the main loop is blinking, apparently without any disturbance from the interrupts. The sketch below works as expected as long as the ISR trigger is FALLING. This question is not for a project, I am just trying to understand what happens and why.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |