peek()

描述

從序列埠收到並放在緩衝區的資料中,取得下次呼叫 read() 會得到的值。使用這個函式並不會減少緩衝區的資料總數,換句話說,透過 peek() 成功取得值後,下次用 read() 也會得到相同的值。

peek() 是繼承於 Stream 類別。

語法

適用所有板子:

Serial.peek()
Serial1.peek()

適用 86Duino ONE:

Serial2.peek()
Serial3.peek()
Serial485.peek()

適用 86Duino EduCake:

Serial2.peek()
Serial3.peek()
Serial232.peek()

參數

回傳

緩衝區內第一個可用的 byte (假如緩衝區內沒有值,則回傳 -1) – int 型別

See also

Serial
available()
begin()
end()
find()
findUntil()
flush()
parseFloat()
parseInt()
print()
println()
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.