println()
描述
透過序列埠印出具有閱讀性的 ASCII 文字,後面再接著回車字元 (ASCII 13 或 ‘\r’) 和新列字元 (ASCII 10 或 ‘\n’)。這個函式和 Serial.print() 有相同的格式。
語法
Serial.println(val)
Serial.println(val, format)
參數
val: 要印的值 – 任意型別
format: 指定印出的格式 (對於整數的資料型別) 或小數點後的位數 (對於符點數資料型別)
回傳
size_t (long):print() 的 byte 數
範例
/*
  類比訊號輸入
 從類比訊號腳 0 讀取類比訊號,然後印出讀到的值
 created 24 March 2006
 by Tom Igoe
 */
int analogValue = 0;    // 儲存類比值的變數
void setup() {
  // 設定 Serial 為 9600 鮑率
  Serial.begin(9600);
}
void loop() {
  // read the analog input on pin 0:
  analogValue = analogRead(0);
  // print it out in many formats:
  Serial.println(analogValue);       // 印出十進位格式的數字
  Serial.println(analogValue, DEC);  // 印出十進位格式的數字
  Serial.println(analogValue, HEX);  // 印出十六進位格式的數字
  Serial.println(analogValue, OCT);  // 印出八進位格式的數字
  Serial.println(analogValue, BIN);  // 印出二進位格式的數字
  // 延遲 10 毫秒後再讀取類比訊號
  delay(10);
}
See also
- Serial
- available()
- begin()
- end()
- find()
- findUntil()
- flush()
- parseFloat()
- parseInt()
- peek()
- print()
- read()
- readBytes()
- readBytesUntil()
- setTimeout()
- write()
- serialEvent()
The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.
