0
0
Embedded Cprogramming~10 mins

Button debouncing in software in Embedded C - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to read the button state.

Embedded C
int buttonState = [1](buttonPin);
Drag options to blanks, or click blank then click option'
AdigitalRead
BcheckButton
CgetButton
DreadButton
Attempts:
3 left
💡 Hint
Common Mistakes
Using a function that does not read input pins.
2fill in blank
medium

Complete the code to check if the button is pressed (active low).

Embedded C
if (buttonState == [1]) {
    // Button pressed
}
Drag options to blanks, or click blank then click option'
AHIGH
B1
C0
DLOW
Attempts:
3 left
💡 Hint
Common Mistakes
Checking for HIGH instead of LOW.
3fill in blank
hard

Fix the error in the debounce delay function call.

Embedded C
delay([1]);
Drag options to blanks, or click blank then click option'
A5
B50
C500
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using too short or too long delay causing missed presses or lag.
4fill in blank
hard

Fill both blanks to complete the debounce logic.

Embedded C
if (buttonState == [1] && lastButtonState == [2]) {
    lastDebounceTime = millis();
}
Drag options to blanks, or click blank then click option'
ALOW
BHIGH
C0
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up current and last button states.
5fill in blank
hard

Fill all three blanks to complete the stable button press detection.

Embedded C
if ((millis() - lastDebounceTime) > [1]) {
    if (buttonState != [2]) {
        buttonState = [3];
        // Button state changed
    }
}
Drag options to blanks, or click blank then click option'
A50
BlastButtonState
Creading
DdebounceDelay
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong variables for timing or state comparison.