> For the complete documentation index, see [llms.txt](https://ubtechedu.gitbook.io/chinese/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ubtechedu.gitbook.io/chinese/arduino-language/functions/communication/println.md).

# Serial.println(val,format)

打印数据到串行端口，输出人们可识别的ASCII码文本并回车

### 参数

| 参数名        | 描述                      |
| ---------- | ----------------------- |
| val        | 打印输出的值 - 任何数据类型         |
| format(可选) | 指定进制（整数数据类型）或小数位数（浮点类型） |

### 返回

| 参数名    | 描述                                   |
| ------ | ------------------------------------ |
| number | print()将返回写入的字节数，但是否使用（或读出）这个数字是可设定的 |

### 例子 <a href="#li-zi" id="li-zi"></a>

```c
/*
 模拟输入信号
 读取模拟口0的模拟输入，打印输出读取的值。
 由 Tom Igoe创建于2006年3月24日
 */
 
int analogValue = 0;    // 定义一个变量来保存模拟值
 
void setup() {
  //设置串口波特率为9600 bps：
  Serial.begin(9600);
}
 
void loop() {
  //读取引脚0的模拟输入：
  analogValue = analogRead（0）;
 
  //打印g各种格式：
  Serial.println(analogValue);       //打印ASCII编码的十进制
  Serial.println(analogValue, DEC);  //打印ASCII编码的十进制
  Serial.println(analogValue, HEX);  //打印ASCII编码的十六进制
  Serial.println(analogValue, OCT);  //打印ASCII编码的八进制
  Serial.println(analogValue, BIN);  //打印一个ASCII编码的二进制
 
  // 延时10毫秒：
  delay(10);
}
```
