[Serial]
描述
Writes binary data to the serial port. This data is sent as a byte or series of bytes; to send the characters representing the digits of a number use the print() function instead.
語法
Serial.write(val)
Serial.write(str)
Serial.write(buf, len)
參數
val: a value to send as a single bytestr: a string to send as a series of bytesbuf: an array to send as a series of byteslen: the length of the buffer
回傳
byte: write() will return the number of bytes written, though reading that number is optional
範例
void setup(){
Serial.begin(9600);
}
void loop(){
Serial.write(45); // send a byte with the value 45
int bytesSent = Serial.write("hello"); // send the string "hello" and
// return the length of the string.
}參考
- if (Serial)
- available()
- begin()
- end()
- find()
- findUntil()
- flush()
- parseFloat()
- parseInt()
- peek()
- print()
- println()
- read()
- readBytes()
- readBytesUntil()
- setTimeout()
- serialEvent()
語法參考主頁面
86Duino 參考的文本是根據 知識共享署名-相同方式分享 3.0 許可證,部分文本是從 Arduino 參考 修改的。 參考中的代碼示例已發佈到公共領域。