The digital pin can be either High or Low. Which can mean in logic Zero or One.
This input can be the state of push button, input voltage in binary form or you may use analog input to Arduino digital inputs as a way of quantization.
In real life you can use it to sense the logic state of a button (ON/OFF Switch or Push Button) to check its position.
You can also use it to sense the presence of voltage as an input to Arduino form another circuit.
Use of relays can be considered as a digital input to Arduino.
digitalRead()
[Digital I/O]Description
Reads the value from a specified digital pin, either 
HIGH or LOW.Syntax
digitalRead(pin)Parameters
pin: the number of the digital pin you want to readReturns
HIGH or LOWExample Code
Sets pin 13 to the same value as pin 7, declared as an input.
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
}
Arduino
Check our books on Amazon we created on our way to find happiness.A Trip To Siwa Oasis
 


![A Trip To Siwa Oasis: Tourist guide to an Egyptian Oasis by [ElSakhawy, Sara M.]](https://images-na.ssl-images-amazon.com/images/I/51-IGAzLKML.jpg)
![The Ultimate travel bag list by [ Elskhawy, Sara M.]](https://images-na.ssl-images-amazon.com/images/I/51OlVgqIcwL.jpg)
![Why to Travel?: Travel Like an Insider by [M., Sara]](https://images-na.ssl-images-amazon.com/images/I/51BsVhmk3ZL.jpg)
![3 Easy steps to plan your trip: Travel Like an Insider by [Elskhawy, Sara M.]](https://images-na.ssl-images-amazon.com/images/I/51GRc%2BnSxAL.jpg)
![Solar Artwork: How to Make Your Own Solar Masterpiece by [Ebeed, Ahmed]](https://images-na.ssl-images-amazon.com/images/I/51wT6i0RXNL.jpg)
![Backyard Wind Turbines: Harness wind power with simple and fun projects by [Ebeed, Ahmed]](https://images-na.ssl-images-amazon.com/images/I/51JEcdMP8JL.jpg)

 
 
No comments:
Post a Comment