Complete the code to read the state of a digital input pin.
int pinState = digitalRead([1]);The function digitalRead reads the state of the specified digital pin number. Pin 13 is commonly used for input or output on many boards.
Complete the code to check if the digital input pin reads HIGH.
if (digitalRead(7) == [1]) { // Pin is HIGH }
To check if a pin is HIGH, compare the result of digitalRead to HIGH.
Fix the error in reading the digital input pin state.
pinMode(8, INPUT); int state = digitalRead([1]);
The pin number used in digitalRead must match the pin set as input with pinMode. Here, pin 8 is configured as input, so digitalRead should use 8.
Fill both blanks to read a digital input pin and check if it is LOW.
pinMode([1], INPUT); if (digitalRead([2]) == LOW) { // Pin is LOW }
Set pin 4 as input and read from pin 4 to check if it is LOW.
Fill all three blanks to read a digital input pin, store its state, and check if it is HIGH.
pinMode([1], INPUT); int state = digitalRead([2]); if (state == [3]) { // Pin is HIGH }
The pin number used in pinMode and digitalRead must match. Here, set pin 2 as input, read from pin 2, and check if state is HIGH.