Professional Documents
Culture Documents
FUNCTIONS
digitalRead()
VARIABLES
[Digital I/O]
STRUCTURE
LIBRARIES Description
GLOSSARY Reads the value from a specified digital pin, either HIGH or LOW .
Doubts on how to use Github? pin : the number of the digital pin you want to read
Learn everything you need to
know in this tutorial.
HIGH or LOW
EDIT THIS PAGE
Example Code
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 isnt 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.
See also
LANGUAGE digitalWrite()
LANGUAGE pinMode()
EXAMPLE Tutorial: (Digital Pins)
NEWSLETTER
Copyright Notice
Contact Us
About Us
Careers
2017 Arduino