@@ -27,15 +27,15 @@ An optional second parameter specifies the base (format) to use; permitted value
27
27
* `Serial.print(78, OCT) gives "116"` +
28
28
* `Serial.print(78, DEC) gives "78"` +
29
29
* `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"`
33
33
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:
35
35
36
36
`Serial.print(F(“Hello World”))`
37
37
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()].
39
39
[%hardbreaks]
40
40
41
41
@@ -71,18 +71,16 @@ To send a single byte, use link:../write[Serial.write()].
71
71
[source,arduino]
72
72
----
73
73
/*
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.
75
75
*/
76
- int x = 0; // variable
77
-
78
76
void setup() {
79
77
Serial.begin(9600); // open the serial port at 9600 bps:
80
78
}
81
79
82
80
void loop() {
83
81
// 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
86
84
87
85
Serial.print("DEC");
88
86
Serial.print("\t");
@@ -94,10 +92,9 @@ void loop() {
94
92
Serial.print("\t");
95
93
96
94
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
100
96
97
+ for (int x = 0; x < 64; x++) { // only part of the ASCII chart, change to suit
101
98
// print it out in many formats:
102
99
Serial.print(x); // print as an ASCII-encoded decimal - same as "DEC"
103
100
Serial.print("\t\t"); // prints two tabs to accomodate the label lenght
@@ -112,10 +109,10 @@ void loop() {
112
109
Serial.print("\t"); // prints a tab
113
110
114
111
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"
116
113
delay(200); // delay 200 milliseconds
117
114
}
118
- Serial.println(""); // prints another carriage return
115
+ Serial.println(); // prints another carriage return
119
116
}
120
117
----
121
118
[%hardbreaks]
0 commit comments