Skip to content

Commit 482c0de

Browse files
author
SimonePDA
authored
Merge pull request #374 from per1234/f-macro-link
Improve Serial.print() page
2 parents 81be3b7 + dd79d73 commit 482c0de

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

Language/Functions/Communication/Serial/print.adoc

+12-15
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ An optional second parameter specifies the base (format) to use; permitted value
2727
* `Serial.print(78, OCT) gives "116"` +
2828
* `Serial.print(78, DEC) gives "78"` +
2929
* `Serial.print(78, HEX) gives "4E"` +
30-
* `Serial.println(1.23456, 0) gives "1"` +
31-
* `Serial.println(1.23456, 2) gives "1.23"` +
32-
* `Serial.println(1.23456, 4) gives "1.2346"`
30+
* `Serial.print(1.23456, 0) gives "1"` +
31+
* `Serial.print(1.23456, 2) gives "1.23"` +
32+
* `Serial.print(1.23456, 4) gives "1.2346"`
3333

34-
You can pass flash-memory based strings to Serial.print() by wrapping them with F(). For example:
34+
You can pass flash-memory based strings to Serial.print() by wrapping them with link:../../../../variables/utilities/progmem[F()]. For example:
3535

3636
`Serial.print(F(“Hello World”))`
3737

38-
To send a single byte, use link:../write[Serial.write()].
38+
To send data without conversion to its representation as characters, use link:../write[Serial.write()].
3939
[%hardbreaks]
4040

4141

@@ -71,18 +71,16 @@ To send a single byte, use link:../write[Serial.write()].
7171
[source,arduino]
7272
----
7373
/*
74-
Uses a FOR loop for data and prints a number in various formats.
74+
Uses a for loop to print numbers in various formats.
7575
*/
76-
int x = 0; // variable
77-
7876
void setup() {
7977
Serial.begin(9600); // open the serial port at 9600 bps:
8078
}
8179
8280
void loop() {
8381
// print labels
84-
Serial.print("NO FORMAT"); // prints a label
85-
Serial.print("\t"); // prints a tab
82+
Serial.print("NO FORMAT"); // prints a label
83+
Serial.print("\t"); // prints a tab
8684
8785
Serial.print("DEC");
8886
Serial.print("\t");
@@ -94,10 +92,9 @@ void loop() {
9492
Serial.print("\t");
9593
9694
Serial.print("BIN");
97-
Serial.println("\t"); // carriage return after the last label
98-
99-
for(x=0; x< 64; x++){ // only part of the ASCII chart, change to suit
95+
Serial.println(); // carriage return after the last label
10096
97+
for (int x = 0; x < 64; x++) { // only part of the ASCII chart, change to suit
10198
// print it out in many formats:
10299
Serial.print(x); // print as an ASCII-encoded decimal - same as "DEC"
103100
Serial.print("\t\t"); // prints two tabs to accomodate the label lenght
@@ -112,10 +109,10 @@ void loop() {
112109
Serial.print("\t"); // prints a tab
113110
114111
Serial.println(x, BIN); // print as an ASCII-encoded binary
115-
// then adds the carriage return with "println"
112+
// then adds the carriage return with "println"
116113
delay(200); // delay 200 milliseconds
117114
}
118-
Serial.println(""); // prints another carriage return
115+
Serial.println(); // prints another carriage return
119116
}
120117
----
121118
[%hardbreaks]

0 commit comments

Comments
 (0)