在 Arduino 中列印換行符和製表符
要列印換行符,你可以在文字中引入 '
' 字元,或者使用 Serial.println() 而不是 Serial.print()
示例程式碼如下 −
示例
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println();
Serial.print("This is line1
This is line2
");
Serial.println("This is line3");
Serial.println("This is line4");
}
void loop() {
// put your main code here, to run repeatedly:
}以上程式碼的序列埠監視器輸出為 −
輸出

要新增製表符,你可以在程式碼中引入 '\t'。
示例程式碼如下 −
示例
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println();
Serial.print("This is left half\tThis is right half
");
}
void loop() {
// put your main code here, to run repeatedly:
}相應的序列埠監視器輸出為 −
輸出

廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
安卓
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP