Wire.read()
- 描述
这个函数在调用requestFrom()之后读取从外围设备传输到控制器设备的字节,或者从控制器设备传输到外围设备的字节。read()继承自Stream实用程序类。
- 语法
Wire.read()
- 参数
None.
- Returns
收到的下一个字节
- Example
#include <Wire.h>
void setup() {
Wire.begin(); // Join I2C bus (address is optional for controller device)
Serial.begin(9600); // Start serial for output
}
void loop() {
Wire.requestFrom(2, 6); // Request 6 bytes from slave device number two
// Slave may send less than requested
while(Wire.available()) {
char c = Wire.read(); // Receive a byte as character
Serial.print(c); // Print the character
}
delay(500);
}