Recall & Review
beginner
What does ISR stand for in Arduino programming?
ISR stands for Interrupt Service Routine. It is a special function that runs automatically when an interrupt occurs.
Click to reveal answer
beginner
Why should ISRs be kept short and fast?
ISRs should be short and fast because they pause the main program. Long ISRs can cause delays and missed interrupts, making the program less responsive.
Click to reveal answer
intermediate
Can you use functions like delay() inside an ISR? Why or why not?
No, you should not use delay() inside an ISR because delay() relies on interrupts to count time. Since interrupts are disabled during an ISR, delay() will not work and can cause the program to freeze.
Click to reveal answer
intermediate
How should variables shared between an ISR and the main program be handled?
Variables shared between ISR and main code should be declared as volatile. This tells the compiler the variable can change anytime, preventing wrong optimizations.
Click to reveal answer
beginner
What is the best way to communicate data from an ISR to the main program?
The best way is to set a flag or update a simple variable inside the ISR, then check and handle it in the main loop. Avoid complex processing inside the ISR.
Click to reveal answer
What happens to the main program when an ISR runs?
✗ Incorrect
When an ISR runs, the main program pauses until the ISR completes.
Which keyword should you use for variables shared between ISR and main code?
✗ Incorrect
The volatile keyword tells the compiler the variable can change unexpectedly, which is important for ISR shared variables.
Which of these is safe to do inside an ISR?
✗ Incorrect
Setting a simple flag variable is safe and recommended inside an ISR.
Why should ISRs avoid long or complex code?
✗ Incorrect
Long ISRs block other interrupts and delay the main program, reducing responsiveness.
What happens if you use delay() inside an ISR?
✗ Incorrect
delay() relies on interrupts, which are disabled during an ISR, so it will not work and can freeze the program.
Explain why ISRs should be short and what you should avoid doing inside them.
Think about how ISRs affect the main program's flow and timing.
You got /4 concepts.
Describe how to safely share data between an ISR and the main Arduino program.
Focus on variable declaration and communication method.
You got /4 concepts.