🌐
Arduino
arduino.cc › en › Reference › digitalRead
digitalRead() | Arduino Documentation
Use the following function to read the value of a digital pin: digitalRead(pin) The function admits the following parameter: pin: the Arduino pin number you want to read. The function returns the boolean state of the read pin as · HIGH or · LOW. Control the Arduino built-in LED on pin 13 ...
🌐
DeepBlue
deepbluembedded.com › home › blog › arduino digitalread() digital input tutorial
Arduino digitalread() Digital Input Tutorial
August 17, 2023 - The Arduino GPIO (digital IO) pins can be configured as digital input pins to be used for reading digital inputs (like push buttons, sensors, etc). In order to configure a digital IO pin as an input, we need to use the pinMode() function.
People also ask

Do I need to call pinMode() before every digitalWrite() or digitalRead()?
You only need to call pinMode() once per pin, typically in setup(). After that, digitalWrite() and digitalRead() work for the full duration of the program.
🌐
controllerstech.com
controllerstech.com › home › arduino › core tutorials › digitalwrite() and digitalread() tutorial
Arduino digitalWrite() and digitalRead(): Complete Guide with Examples
Can I use digitalRead() on an analog pin?
Yes. Analog pins A0–A5 on the UNO can be used as digital inputs. Set them with pinMode(A0, INPUT) and read with digitalRead(A0).
🌐
controllerstech.com
controllerstech.com › home › arduino › core tutorials › digitalwrite() and digitalread() tutorial
Arduino digitalWrite() and digitalRead(): Complete Guide with Examples
Can I use any pin for digitalRead()?
Yes. All digital pins (D0–D13 on UNO) and the analog pins (A0–A5) can be used as digital inputs with digitalRead().
🌐
controllerstech.com
controllerstech.com › home › arduino › core tutorials › digitalwrite() and digitalread() tutorial
Arduino digitalWrite() and digitalRead(): Complete Guide with Examples
🌐
Arduino
docs.arduino.cc › built-in-examples › basics › DigitalReadSerial
Digital Read Serial | Arduino Documentation
When the pushbutton is open (unpressed) there is no connection between the two legs of the pushbutton, so the pin is connected to ground (through the pull-down resistor) and reads as LOW, or 0. When the button is closed (pressed), it makes a connection between its two legs, connecting the pin to 5 volts, so that the pin reads as HIGH, or 1. If you disconnect the digital i/o pin from everything, its reading may change erratically.
🌐
Flavio Copes
flaviocopes.com › home › arduino › arduino project: read a digital input
Arduino project: read a digital input - Flavio Copes
March 22, 2021 - Learn how to read a digital input on an Arduino with the digitalRead() function, wiring a button to pin 3 with INPUT_PULLUP to detect when it is pressed.
🌐
Arduino Getting Started
arduinogetstarted.com › reference › digitalread
digitalRead() | Arduino Getting Started
3 weeks ago - int ledPin = 13; // LED connected to digital pin 13 int inPin = 7; // pushbutton connected to digital pin 7 int val = 0; // variable to store the read value void setup() { pinMode(ledPin, OUTPUT); // sets the digital pin 13 as output pinMode(inPin, INPUT); // sets the digital pin 7 as input } void loop() { val = digitalRead(inPin); // read the input pin digitalWrite(ledPin, val); // sets the LED to the button's value } ... If the pin isn't connected to anything, digitalRead() can return either HIGH or LOW (and this can change randomly). The analog input pins can be used as digital pins, referred to as A0, A1, etc. The exception is the Arduino Nano, Pro Mini, and Mini's A6 and A7 pins, which can only be used as analog inputs.
🌐
Technetronelectronics
technetronelectronics.com › home › how to use digitalread in arduino?
How to Use digitalRead in Arduino? - Technetron Electronics
January 2, 2025 - Some boards may have specific pins ... in use for their primary functions. The digital value is read from GPIO (General-Purpose Input/Output) pins using the digitalRead() function in Arduino....
🌐
ControllersTech®
controllerstech.com › home › arduino › core tutorials › digitalwrite() and digitalread() tutorial
Arduino digitalWrite() and digitalRead(): Complete Guide with Examples
May 29, 2026 - By default, Arduino pins start as inputs. Calling digitalWrite() on an unconfigured pin can produce unexpected results or cause the floating pin problem. Why does the button logic seem reversed when using INPUT_PULLUP? With INPUT_PULLUP, the pin reads HIGH when the button is not pressed and LOW when pressed.
🌐
Stanford CCRMA
ccrma.stanford.edu › ~fgeorg › 250a › lab2 › arduino-0019 › reference › DigitalRead.html
Arduino - DigitalRead
int ledPin = 13; // LED connected to digital pin 13 int inPin = 7; // pushbutton connected to digital pin 7 int val = 0; // variable to store the read value void setup() { pinMode(ledPin, OUTPUT); // sets the digital pin 13 as output pinMode(inPin, INPUT); // sets the digital pin 7 as input } void loop() { val = digitalRead(inPin); // read the input pin digitalWrite(ledPin, val); // sets the LED to the button's value }
Find elsewhere
🌐
Arduino Forum
forum.arduino.cc › projects › programming
DigitalRead - use 0 and 1, or HIGH and LOW ? - Programming - Arduino Forum
March 21, 2021 - Hi When reading the state of an output pin to an int variable, is it acceptable to use HIGH / LOW as the result in an IF statement ? int Status1 = 0; Status1 = digitalRead(OutPin6); if (Status1 == HIGH)…
🌐
TutorialsPoint
tutorialspoint.com › digital-read-in-arduino
Arduino - Reading Analog Voltage
May 29, 2021 - */ // the setup routine runs once ... and over again forever: void loop() { // read the input on analog pin 0: int sensorValue = analogRead(A0); // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V): ...
🌐
Particle
docs.particle.io › reference › device-os › api › input-output › digitalread
digitalRead() - Input/Output | Reference | Particle
// EXAMPLE USAGE int button = D0; // button is connected to D0 int LED = D1; // LED is connected to D1 int val = 0; // variable to store the read value void setup() { pinMode(LED, OUTPUT); // sets pin as output pinMode(button, INPUT_PULLDOWN); // sets pin as input } void loop() { val = digitalRead(button); // read the input pin digitalWrite(LED, val); // sets the LED to the button's value }
🌐
Newmedia
learn.newmedia.dog › tutorials › arduino-and-electronics › arduino › digital-io-digitalread
Digital Input: digitalRead() | Aalto New Media
October 27, 2024 - Reading digital signals with the Arduino or any other microcontroller is quite simple. You can just use the function digitalRead() which returns a HIGH or LOW depending on the voltage of the pin that you read. Schematic # Breadboard View # Code # The code below does the following: int btnPin ...
🌐
The Engineering Projects
theengineeringprojects.com › home › blog › arduino › how to use digitalread in arduino ?
How to use digitalRead in Arduino ? - The Engineering Projects
December 5, 2018 - Now, coming towards digitalRead command, this digitalRead command is used in Arduino for reading the status of digital Pins on Arduino.
🌐
Puriphico
puriphico.com › post › digitalread-digital-functions-in-arduino-programming-part-2
digitalRead(): digital functions in arduino programming (part 2)
June 15, 2021 - When a pin is configured to be ... digitalRead function in your Arduino program, write digitalRead(pin), where 'pin' refers to the pin number labeled on the microcontroller....
🌐
Arduino Forum
forum.arduino.cc › projects › programming
digitalRead() return value, please advise variable type - Programming - Arduino Forum
January 10, 2021 - Syntax digitalRead(pin) Parameters pin: the Arduino pin number you want to read Returns HIGH or LOW example shows function return value variable as an integer? int ledPin = 13; // LED connected to digital pin 13 int inPin = 7; // pushbutton connected to digital pin 7 int val = 0; // va...
🌐
Arduino
docs.arduino.cc › language-reference › funktionen › digital-io › digitalread
Arduino
The official Arduino programming language structure reference pages.
🌐
Linux Hint
linuxhint.com › digital-read-arduino
Linux Hint – Linux Hint
Linux Hint LLC, [email protected] 1210 Kelly Park Circle, Morgan Hill, CA 95037 Privacy Policy and Terms of Use
🌐
FC2
garretlab.web.fc2.com › top › arduino › internal structure of arduino software › avr › wiring_digital.c › digitalread()
digitalRead() - garretlab - FC2
July 31, 2025 - The digitalRead() returns if the specified pin is HIGH or LOW. If the value of the corresponding bit of the register is 1 it returns HIGH, if 0 it returns LOW. There are three registers, PORTB, PORTC and PORTD. The relation of the bit of the registers and the pins of Arduino Uno is shown below.