Skip to content

Commit 864d3b4

Browse files
author
Akshay Sharma
committed
Add Content Functions/Digital IO
1 parent 0385efa commit 864d3b4

File tree

4 files changed

+1134
-0
lines changed

4 files changed

+1134
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
:source-highlighter: pygments
2+
:pygments-style: arduino
3+
//:ext-relative: adoc
4+
:ext-relative: .html
5+
6+
= digitalRead()
7+
8+
9+
// OVERVIEW SECTION STARTS
10+
[#overview]
11+
--
12+
13+
[float]
14+
=== Description
15+
Reads the value from a specified digital pin, either `HIGH` or `LOW`.
16+
[%hardbreaks]
17+
18+
19+
[float]
20+
=== Syntax
21+
`digitalRead(pin)`
22+
23+
24+
[float]
25+
=== Parameters
26+
27+
28+
[float]
29+
=== Returns
30+
`HIGH` or `LOW`
31+
32+
--
33+
// OVERVIEW SECTION ENDS
34+
35+
36+
37+
38+
// HOW TO USE SECTION STARTS
39+
[#howtouse]
40+
--
41+
42+
[float]
43+
=== Example Code
44+
// Describe what the example code is all about and add relevant code ►►►►► THIS SECTION IS MANDATORY ◄◄◄◄◄
45+
Sets pin 13 to the same value as pin 7, declared as an input.
46+
47+
//[source,arduino]
48+
----
49+
int ledPin = 13; // LED connected to digital pin 13
50+
int inPin = 7; // pushbutton connected to digital pin 7
51+
int val = 0; // variable to store the read value
52+
53+
void setup()
54+
{
55+
pinMode(ledPin, OUTPUT); // sets the digital pin 13 as output
56+
pinMode(inPin, INPUT); // sets the digital pin 7 as input
57+
}
58+
59+
void loop()
60+
{
61+
val = digitalRead(inPin); // read the input pin
62+
digitalWrite(ledPin, val); // sets the LED to the button's value
63+
}
64+
----
65+
[%hardbreaks]
66+
67+
[float]
68+
=== Notes and Warnings
69+
If the pin isn't connected to anything, digitalRead() can return either HIGH or LOW (and this can change randomly).
70+
71+
The analog input pins can be used as digital pins, referred to as A0, A1, etc.
72+
[%hardbreaks]
73+
74+
[float]
75+
=== See also
76+
// Link relevant content by category, such as other Reference terms (please add the tag #LANGUAGE#),
77+
// definitions (please add the tag #DEFINITION#), and examples of Projects and Tutorials
78+
// (please add the tag #EXAMPLE#) ►►►►► THIS SECTION IS MANDATORY ◄◄◄◄◄
79+
[role="language"]
80+
* #LANGUAGE# link:pinMode{ext-relative}[pinMode()] +
81+
* #LANGUAGE# link:digitalWrite{ext-relative}[digitalWrite()]
82+
83+
[role="example"]
84+
* #EXAMPLE# Tutorial: (http://arduino.cc/en/Tutorial/DigitalPins[Digital Pins])
85+
86+
--
87+
// HOW TO USE SECTION ENDS

0 commit comments

Comments
 (0)