SoftwareSerial: peek

描述

回传软体序列介面接收到的资料。不过与 read() 并不相同,在不呼叫 read() 前,每次呼叫 peek() 得到的字元都是相同的。

请注意,同一时间只能有一个 SoftwareSerial 物件接收资料,监听指定 SoftwareSerial 物件请呼叫 listen()

参数

无参数

回传

char:回传软体序列介面接收到的资料中最先收到的字元,如果没有资料可以读则回传 -1

范例

SoftwareSerial mySerial(10,11);

void setup()
{
  mySerial.begin(9600);
}

void loop()
{
  char c = mySerial.peek();
}

See also

SoftwareSerial()
begin()
read()
print()
println()


函式库参考主页面

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.