Skip to content

Commit 7c90a6d

Browse files
author
Akshay Sharma
committed
Add Content Functions (Most of the the Terms)
1 parent f772195 commit 7c90a6d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+4912
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
:source-highlighter: pygments
2+
:pygments-style: arduino
3+
:ext-relative: adoc
4+
5+
6+
= available()
7+
8+
9+
// OVERVIEW SECTION STARTS
10+
[#overview]
11+
--
12+
13+
[float]
14+
=== Description
15+
Get the number of bytes (characters) available for reading from the serial port. This is data that's already arrived and stored in the serial receive buffer (which holds 64 bytes). `available()` inherits from the Stream utility class.
16+
[%hardbreaks]
17+
18+
19+
[float]
20+
=== Syntax
21+
`Serial.available()`
22+
23+
_Arduino Mega only:_
24+
25+
`Serial1.available()` +
26+
`Serial2.available()` +
27+
`Serial3.available()`
28+
29+
30+
[float]
31+
=== Parameters
32+
Nothing
33+
34+
[float]
35+
=== Returns
36+
The number of bytes available to read .
37+
--
38+
// OVERVIEW SECTION ENDS
39+
40+
41+
42+
43+
// HOW TO USE SECTION STARTS
44+
[#howtouse]
45+
--
46+
47+
[source,arduino]
48+
----
49+
int incomingByte = 0; // for incoming serial data
50+
51+
void setup() {
52+
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
53+
}
54+
55+
void loop() {
56+
57+
// send data only when you receive data:
58+
if (Serial.available() > 0) {
59+
// read the incoming byte:
60+
incomingByte = Serial.read();
61+
62+
// say what you got:
63+
Serial.print("I received: ");
64+
Serial.println(incomingByte, DEC);
65+
}
66+
}
67+
----
68+
[%hardbreaks]
69+
70+
*Arduino Mega example:*
71+
[source,arduino]
72+
----
73+
void setup() {
74+
Serial.begin(9600);
75+
Serial1.begin(9600);
76+
77+
}
78+
79+
void loop() {
80+
// read from port 0, send to port 1:
81+
if (Serial.available()) {
82+
int inByte = Serial.read();
83+
Serial1.print(inByte, BYTE);
84+
85+
}
86+
// read from port 1, send to port 0:
87+
if (Serial1.available()) {
88+
int inByte = Serial1.read();
89+
Serial.print(inByte, BYTE);
90+
}
91+
}
92+
----
93+
94+
[float]
95+
=== See also
96+
// Link relevant content by category, such as other Reference terms (please add the tag #LANGUAGE#),
97+
// definitions (please add the tag #DEFINITION#), and examples of Projects and Tutorials
98+
// (please add the tag #EXAMPLE#) ►►►►► THIS SECTION IS MANDATORY ◄◄◄◄◄
99+
[role="language"]
100+
* #LANGUAGE# link:begin{ext-relative}[begin()] +
101+
* #LANGUAGE# link:end{ext-relative}[end()] +
102+
* #LANGUAGE# link:available{ext-relative}[available()] +
103+
* #LANGUAGE# link:read{ext-relative}[read()] +
104+
* #LANGUAGE# link:peek{ext-relative}[peek()] +
105+
* #LANGUAGE# link:flush{ext-relative}[flush()] +
106+
* #LANGUAGE# link:print{ext-relative}[print()] +
107+
* #LANGUAGE# link:println{ext-relative}[println()] +
108+
* #LANGUAGE# link:write{ext-relative}[write()] +
109+
* #LANGUAGE# link:serialEvent{ext-relative}[SerialEvent()] +
110+
* #LANGUAGE# link:serialAvailable{ext-relative}[(Serial.available)]
111+
112+
--
113+
// HOW TO USE SECTION ENDS
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
:source-highlighter: pygments
2+
:pygments-style: arduino
3+
:ext-relative: adoc
4+
5+
6+
= begin()
7+
8+
9+
// OVERVIEW SECTION STARTS
10+
[#overview]
11+
--
12+
13+
[float]
14+
=== Description
15+
Sets the data rate in bits per second (baud) for serial data transmission. For communicating with the computer, use one of these rates: 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, or 115200. You can, however, specify other rates - for example, to communicate over pins 0 and 1 with a component that requires a particular baud rate.
16+
17+
An optional second argument configures the data, parity, and stop bits. The default is 8 data bits, no parity, one stop bit.
18+
[%hardbreaks]
19+
20+
21+
[float]
22+
=== Syntax
23+
`Serial.begin(speed)`
24+
`Serial.begin(speed, config)`
25+
26+
_Arduino Mega only:_
27+
28+
`Serial1.begin(speed)` +
29+
`Serial2.begin(speed)` +
30+
`Serial3.begin(speed)` +
31+
`Serial1.begin(speed, config)` +
32+
`Serial2.begin(speed, config)` +
33+
`Serial3.begin(speed, config)`
34+
35+
36+
37+
[float]
38+
=== Parameters
39+
`speed`: in bits per second (baud) - `long`
40+
41+
`config`: sets data, parity, and stop bits. Valid values are
42+
43+
`SERIAL_5N1` +
44+
`SERIAL_6N1` +
45+
`SERIAL_7N1` +
46+
`SERIAL_8N1` (the default) +
47+
`SERIAL_5N2` +
48+
`SERIAL_6N2` +
49+
`SERIAL_7N2` +
50+
`SERIAL_8N2` +
51+
`SERIAL_5E1` +
52+
`SERIAL_6E1` +
53+
`SERIAL_7E1` +
54+
`SERIAL_8E1` +
55+
`SERIAL_5E2` +
56+
`SERIAL_6E2` +
57+
`SERIAL_7E2` +
58+
`SERIAL_8E2` +
59+
`SERIAL_5O1` +
60+
`SERIAL_6O1` +
61+
`SERIAL_7O1` +
62+
`SERIAL_8O1` +
63+
`SERIAL_5O2` +
64+
`SERIAL_6O2` +
65+
`SERIAL_7O2` +
66+
`SERIAL_8O2` +
67+
68+
[float]
69+
=== Returns
70+
Nothing
71+
72+
--
73+
// OVERVIEW SECTION ENDS
74+
75+
76+
77+
78+
// HOW TO USE SECTION STARTS
79+
[#howtouse]
80+
--
81+
82+
[float]
83+
=== Example Code
84+
// Describe what the example code is all about and add relevant code ►►►►► THIS SECTION IS MANDATORY ◄◄◄◄◄
85+
86+
87+
[source,arduino]
88+
----
89+
void setup() {
90+
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
91+
}
92+
93+
void loop() {}
94+
----
95+
[%hardbreaks]
96+
97+
*Arduino Mega example:*
98+
[source,arduino]
99+
----
100+
// Arduino Mega using all four of its Serial ports
101+
// (Serial, Serial1, Serial2, Serial3),
102+
// with different baud rates:
103+
104+
void setup(){
105+
Serial.begin(9600);
106+
Serial1.begin(38400);
107+
Serial2.begin(19200);
108+
Serial3.begin(4800);
109+
110+
Serial.println("Hello Computer");
111+
Serial1.println("Hello Serial 1");
112+
Serial2.println("Hello Serial 2");
113+
Serial3.println("Hello Serial 3");
114+
}
115+
void loop() {}
116+
----
117+
[%hardbreaks]
118+
Thanks to Jeff Gray for the mega example
119+
120+
[float]
121+
=== See also
122+
// Link relevant content by category, such as other Reference terms (please add the tag #LANGUAGE#),
123+
// definitions (please add the tag #DEFINITION#), and examples of Projects and Tutorials
124+
// (please add the tag #EXAMPLE#) ►►►►► THIS SECTION IS MANDATORY ◄◄◄◄◄
125+
[role="language"]
126+
* #LANGUAGE# link:begin{ext-relative}[begin()] +
127+
* #LANGUAGE# link:end{ext-relative}[end()] +
128+
* #LANGUAGE# link:available{ext-relative}[available()] +
129+
* #LANGUAGE# link:read{ext-relative}[read()] +
130+
* #LANGUAGE# link:peek{ext-relative}[peek()] +
131+
* #LANGUAGE# link:flush{ext-relative}[flush()] +
132+
* #LANGUAGE# link:print{ext-relative}[print()] +
133+
* #LANGUAGE# link:println{ext-relative}[println()] +
134+
* #LANGUAGE# link:write{ext-relative}[write()] +
135+
* #LANGUAGE# link:serialEvent{ext-relative}[SerialEvent()]
136+
137+
--
138+
// HOW TO USE SECTION ENDS
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
:source-highlighter: pygments
2+
:pygments-style: arduino
3+
:ext-relative: adoc
4+
5+
6+
= end()
7+
8+
9+
// OVERVIEW SECTION STARTS
10+
[#overview]
11+
--
12+
13+
[float]
14+
=== Description
15+
Disables serial communication, allowing the RX and TX pins to be used for general input and output. To re-enable serial communication, call link:begin{ext-relative}[Serial.begin()].
16+
[%hardbreaks]
17+
18+
19+
[float]
20+
=== Syntax
21+
`Serial.end()`
22+
23+
_Arduino Mega only:_
24+
25+
`Serial1.end()` +
26+
`Serial2.end()` +
27+
`Serial3.end()` +
28+
29+
30+
[float]
31+
=== Parameters
32+
Nothing
33+
34+
[float]
35+
=== Returns
36+
Nothing
37+
38+
--
39+
// OVERVIEW SECTION ENDS
40+
41+
42+
43+
44+
// HOW TO USE SECTION STARTS
45+
[#howtouse]
46+
--
47+
48+
[float]
49+
=== See also
50+
// Link relevant content by category, such as other Reference terms (please add the tag #LANGUAGE#),
51+
// definitions (please add the tag #DEFINITION#), and examples of Projects and Tutorials
52+
// (please add the tag #EXAMPLE#) ►►►►► THIS SECTION IS MANDATORY ◄◄◄◄◄
53+
[role="language"]
54+
* #LANGUAGE# link:begin{ext-relative}[begin()] +
55+
* #LANGUAGE# link:end{ext-relative}[end()] +
56+
* #LANGUAGE# link:available{ext-relative}[available()] +
57+
* #LANGUAGE# link:read{ext-relative}[read()] +
58+
* #LANGUAGE# link:peek{ext-relative}[peek()] +
59+
* #LANGUAGE# link:flush{ext-relative}[flush()] +
60+
* #LANGUAGE# link:print{ext-relative}[print()] +
61+
* #LANGUAGE# link:println{ext-relative}[println()] +
62+
* #LANGUAGE# link:write{ext-relative}[write()] +
63+
* #LANGUAGE# link:serialEvent{ext-relative}[SerialEvent()]
64+
65+
--
66+
// HOW TO USE SECTION ENDS
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
:source-highlighter: pygments
2+
:pygments-style: arduino
3+
:ext-relative: adoc
4+
5+
6+
= Serial.find()
7+
8+
9+
// OVERVIEW SECTION STARTS
10+
[#overview]
11+
--
12+
13+
[float]
14+
=== Description
15+
Serial.find() reads data from the serial buffer until the target string of given length is found. The function returns true if target string is found, false if it times out.
16+
17+
Serial.find() inherits from the link:stream{ext-relative}[Stream] utility class.
18+
[%hardbreaks]
19+
20+
21+
[float]
22+
=== Syntax
23+
`Serial.find(target)`
24+
25+
[float]
26+
=== Parameters
27+
`target` : the string to search for (char)
28+
29+
[float]
30+
=== Returns
31+
`boolean`
32+
33+
--
34+
// OVERVIEW SECTION ENDS
35+
36+
37+
38+
39+
// HOW TO USE SECTION STARTS
40+
[#howtouse]
41+
--
42+
43+
[float]
44+
=== See also
45+
// Link relevant content by category, such as other Reference terms (please add the tag #LANGUAGE#),
46+
// definitions (please add the tag #DEFINITION#), and examples of Projects and Tutorials
47+
// (please add the tag #EXAMPLE#) ►►►►► THIS SECTION IS MANDATORY ◄◄◄◄◄
48+
[role="language"]
49+
* #LANGUAGE# link:stream{ext-relative}[stream] +
50+
* #LANGUAGE# link:streamFind{ext-relative}[stream.find()]
51+
52+
--
53+
// HOW TO USE SECTION ENDS

0 commit comments

Comments
 (0)