0
0
Embedded Cprogramming~10 mins

Reading digital input pin state 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 state of a digital input pin.

Embedded C
int pinState = digitalRead([1]);
Drag options to blanks, or click blank then click option'
A13
BOUTPUT
C5
DHIGH
Attempts:
3 left
💡 Hint
Common Mistakes
Using pin mode constants like OUTPUT or HIGH instead of a pin number.
Confusing digitalRead with digitalWrite.
2fill in blank
medium

Complete the code to check if the digital input pin reads HIGH.

Embedded C
if (digitalRead(7) == [1]) {
    // Pin is HIGH
}
Drag options to blanks, or click blank then click option'
ALOW
BHIGH
CINPUT
DOUTPUT
Attempts:
3 left
💡 Hint
Common Mistakes
Comparing to pin mode constants like INPUT or OUTPUT.
Using LOW instead of HIGH in the condition.
3fill in blank
hard

Fix the error in reading the digital input pin state.

Embedded C
pinMode(8, INPUT);
int state = digitalRead([1]);
Drag options to blanks, or click blank then click option'
A8
B9
CINPUT
DHIGH
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different pin number than the one set as input.
Passing mode constants like INPUT or HIGH to digitalRead.
4fill in blank
hard

Fill both blanks to read a digital input pin and check if it is LOW.

Embedded C
pinMode([1], INPUT);
if (digitalRead([2]) == LOW) {
    // Pin is LOW
}
Drag options to blanks, or click blank then click option'
A4
BHIGH
D7
Attempts:
3 left
💡 Hint
Common Mistakes
Using different pin numbers in pinMode and digitalRead.
Comparing to HIGH instead of LOW.
5fill in blank
hard

Fill all three blanks to read a digital input pin, store its state, and check if it is HIGH.

Embedded C
pinMode([1], INPUT);
int state = digitalRead([2]);
if (state == [3]) {
    // Pin is HIGH
}
Drag options to blanks, or click blank then click option'
A2
CHIGH
D3
Attempts:
3 left
💡 Hint
Common Mistakes
Using different pin numbers in pinMode and digitalRead.
Comparing to LOW instead of HIGH.