在 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