[Serial]
描述
Reads incoming serial data. read()
inherits from the Stream utility class.
語法
適用所有板子:
Serial.read()
Serial1.read()
適用 86Duino ONE:
Serial2.read()
Serial3.read()
Serial485.read()
適用 86Duino EduCake:
Serial2.read()
Serial3.read()
Serial232.read()
參數
None
回傳
the first byte of incoming serial data available (or -1 if no data is available) – int
範例
int incomingByte = 0; // for incoming serial data void setup() { Serial.begin(9600); // opens serial port, sets data rate to 9600 bps } void loop() { // send data only when you receive data: if (Serial.available() > 0) { // read the incoming byte: incomingByte = Serial.read(); // say what you got: Serial.print("I received: "); Serial.println(incomingByte, DEC); } }
參考
- if (Serial)
- available()
- begin()
- end()
- find()
- findUntil()
- flush()
- parseFloat()
- parseInt()
- peek()
- print()
- println()
- readBytes()
- readBytesUntil()
- setTimeout()
- write()
- serialEvent()
語法參考主頁面
86Duino 參考的文本是根據 Creative Commons Attribution-ShareAlike 3.0 License,部分文本是從 the Arduino reference 修改的。 參考中的代碼示例已發佈到公共領域。