[Serial]
説明
Reads incoming serial data. read() inherits from the Stream utility class.
構文
All boards:
Serial.read()Serial1.read()
86Duino One specific:
Serial2.read()Serial3.read()Serial485.read()
86Duino EduCake specific:
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()
Language Reference Home
86Duinoリファレンスのテキストは、Arduinoリファレンスを改変したもので、Creative Commons Attribution-ShareAlike 3.0ライセンスに基づいてライセンスされています。リファレンス内のコードサンプルはパブリックドメインとして公開されています。