Recall & Review
beginner
What is an interrupt in Arduino programming?
An interrupt is a signal that temporarily stops the main program to run a special function called an interrupt service routine (ISR). It helps respond quickly to events like button presses.
Click to reveal answer
beginner
Why use interrupt-driven button handling instead of polling?
Interrupts let the Arduino react immediately to button presses without constantly checking the button state, saving processing time and power.Click to reveal answer
beginner
What is an ISR (Interrupt Service Routine)?
An ISR is a small function that runs automatically when an interrupt occurs. It should be short and fast to avoid delaying the main program.
Click to reveal answer
intermediate
How do you attach an interrupt to a button pin in Arduino?
Use the attachInterrupt() function with the interrupt number (digitalPinToInterrupt(pin)), the ISR function name, and the trigger mode (e.g., RISING, FALLING).
Click to reveal answer
intermediate
What precautions should you take inside an ISR?
Keep the ISR short, avoid using delay(), Serial.print(), or complex code. Use volatile variables if sharing data with the main program.
Click to reveal answer
What does attachInterrupt() do in Arduino?
✗ Incorrect
attachInterrupt() connects a hardware interrupt on a pin to a function (ISR) that runs when the interrupt triggers.
Which trigger mode calls the ISR when the button signal goes from LOW to HIGH?
✗ Incorrect
RISING triggers the ISR when the signal changes from LOW to HIGH.
Why should ISRs be short and fast?
✗ Incorrect
Long ISRs block other interrupts and slow down the main program, causing problems.
What keyword should you use for variables shared between ISR and main code?
✗ Incorrect
volatile tells the compiler the variable can change unexpectedly, so it always reads the latest value.
Which Arduino pins support external interrupts on most boards?
✗ Incorrect
On many Arduino boards, pins 2 and 3 support external interrupts.
Explain how interrupt-driven button handling works on Arduino.
Think about how the Arduino reacts immediately to a button press without waiting.
You got /5 concepts.
What are the best practices when writing an ISR for a button press?
Consider what could cause problems if the ISR takes too long or uses certain functions.
You got /4 concepts.