Skip to content

Commit 13349a7

Browse files
committed
Add contents for Structure/Main
1 parent 0c56d4d commit 13349a7

File tree

2 files changed

+113
-61
lines changed

2 files changed

+113
-61
lines changed

Language/Structure/Main/loop.adoc

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
:source-highlighter: pygments
2+
:pygments-style: arduino
3+
:ext-relative: adoc
4+
5+
6+
= loop()
7+
8+
9+
// OVERVIEW SECTION STARTS
10+
[#overview]
11+
--
12+
13+
[float]
14+
=== Description
15+
After creating a link:setup{ext-relative}[setup()] function, which initializes and sets the initial values, the `loop()` function does precisely what its name suggests, and loops consecutively, allowing your program to change and respond. Use it to actively control the Arduino board.
16+
[%hardbreaks]
17+
18+
--
19+
// OVERVIEW SECTION ENDS
20+
21+
22+
// HOW TO USE SECTION STARTS
23+
[#howtouse]
24+
--
25+
26+
[float]
27+
=== Example Code
28+
[source,arduino]
29+
----
30+
int buttonPin = 3;
31+
32+
// setup initializes serial and the button pin
33+
void setup()
34+
{
35+
beginSerial(9600);
36+
pinMode(buttonPin, INPUT);
37+
}
38+
39+
// loop checks the button pin each time,
40+
// and will send serial if it is pressed
41+
void loop()
42+
{
43+
if (digitalRead(buttonPin) == HIGH)
44+
serialWrite('H');
45+
else
46+
serialWrite('L');
47+
48+
delay(1000);
49+
}
50+
----
51+
[%hardbreaks]
52+
53+
[float]
54+
=== See also
55+
[role="language"]
56+
* #LANGUAGE# link:setup{ext-relative}[setup()]
57+
[%hardbreaks]
58+
59+
--
60+
// HOW TO USE SECTION ENDS

Language/Structure/Main/setup.adoc

Lines changed: 53 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,53 @@
1-
:source-highlighter: pygments
2-
:pygments-style: arduino
3-
:ext-relative: adoc
4-
5-
= setup()
6-
7-
8-
// OVERVIEW SECTION STARTS
9-
[#overview]
10-
--
11-
12-
[float]
13-
=== Description
14-
The `setup()` function is called when a sketch starts. Use it to initialize variables, pin modes, when you start using libraries, etc. The setup function will only run once, after each powerup or reset of the Arduino board.
15-
[%hardbreaks]
16-
17-
[float]
18-
=== Syntax
19-
`setup()`
20-
21-
[float]
22-
=== Returns
23-
Nothing
24-
25-
--
26-
// OVERVIEW SECTION ENDS
27-
28-
29-
30-
31-
// HOW TO USE SECTION STARTS
32-
[#howtouse]
33-
--
34-
35-
[float]
36-
=== Example Code
37-
38-
[source,arduino]
39-
----
40-
int buttonPin = 3;
41-
42-
void setup()
43-
{
44-
Serial.begin(9600);
45-
pinMode(buttonPin, INPUT);
46-
}
47-
48-
void loop()
49-
{
50-
// ...
51-
}
52-
----
53-
[%hardbreaks]
54-
55-
--
56-
// HOW TO USE SECTION ENDS
57-
58-
[float]
59-
=== See also
60-
[role="language"]
61-
* #LANGUAGE# link:Loop{ext-relative}[loop^]
1+
:source-highlighter: pygments
2+
:pygments-style: arduino
3+
:ext-relative: adoc
4+
5+
6+
= setup()
7+
8+
9+
// OVERVIEW SECTION STARTS
10+
[#overview]
11+
--
12+
13+
[float]
14+
=== Description
15+
The `setup()` function is called when a sketch starts. Use it to initialize variables, pin modes, start using libraries, etc. The `setup()` function will only run once, after each powerup or reset of the Arduino board.
16+
[%hardbreaks]
17+
18+
--
19+
// OVERVIEW SECTION ENDS
20+
21+
22+
// HOW TO USE SECTION STARTS
23+
[#howtouse]
24+
--
25+
26+
[float]
27+
=== Example Code
28+
29+
[source,arduino]
30+
----
31+
int buttonPin = 3;
32+
33+
void setup()
34+
{
35+
Serial.begin(9600);
36+
pinMode(buttonPin, INPUT);
37+
}
38+
39+
void loop()
40+
{
41+
// ...
42+
}
43+
----
44+
[%hardbreaks]
45+
46+
[float]
47+
=== See also
48+
[role="language"]
49+
* #LANGUAGE# link:loop{ext-relative}[loop()]
50+
[%hardbreaks]
51+
52+
--
53+
// HOW TO USE SECTION ENDS

0 commit comments

Comments
 (0)