描述 如果是从端呼叫 write(),表示传送资料到请求资料的主端,如果是主端呼叫 write(),表示传送资料到从端,主端呼叫 write(),应该要在 beginTransmission() 和 endTransmission() 之间。 语法 Wire.write(value) Wire.write(string) Wire.write(data, length) Parameters value:要传送的资料,大小为一个位元组 string:要传送的资料,型态为 string data:一个含有要传的资料的阵列 length:要传送的资料阵列的大小 回传 byte:回传 write() 传送的资料的位元组数量 范例 函式库参考主页面 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 […]
描述 结束传送资料到从端,传送资料开始于 beginTransmission(),endTransmission() 会把 write() 写入暂存区的资料传送出去。 endTransmission() 可以选择要提供或是不提供参数,当不提供该参数时预设为 true,这个参数被用来改变 endTransmission() 的行为,如果该参数为 true 则 endTransmission() 在传送完请求后会传送停止的指令,释放 I2C 介面。如果该参数为 false 则 endTransmission() 在传送完请求后会传送重新启动的指令,不去释放 I2C 介面,使得其他的主端无法发送请求,这样允许一个主端在控制时可以发送多个请求。 语法 Wire.endTransmission() Wire.endTransmission(stop) 参数 stop(非必要):如果 stop 为 true 传送请求后释放 I2C,如果 stop 为 false 传送请求后不释放 I2C,型态为 boolean,预设为 true,详见上面的描述 回传 byte:回传资料传输的状态 -0:成功 -1:资料超过传输的暂存区 -2:在传送位址时收到 NACK -3:在传送资料时收到 NACK -4:其他错误 See also - Wire.beginTransmission() - Wire.write() […]
描述 开始传送资料到指定的 I2C 从端位址,接着呼叫 write() 把资料写入暂存区,最后呼叫 endTransmission() 把暂存区裡的资料传送到从端。 参数 address:从端的七位元位址 回传 无回传值 See also - Wire.write() - Wire.endTransmission() 函式库参考主页面 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.
描述 呼叫 requestFrom() 藉以向 I2C 的从端请求资料。之后再使用 available() 和 read() 读取资料。 requestFrom() 的第三个参数可以选择要提供或是不提供,当不提供该参数时预设为 true,这个参数被用来改变 requestFrom() 的行为,如果该参数为 true 则 requestFrom() 在传送完请求后会传送停止的指令,释放 I2C 介面。如果该参数为 false 则 requestFrom() 在传送完请求后会传送重新启动的指令,不去释放 I2C 介面,使得其他的主端无法发送请求,这样允许一个主端在控制时可以发送多个请求。 语法 Wire.requestFrom(address, quantity) Wire.requestFrom(address, quantity, stop) 参数 address:从端的七位元位址 quantity:请求资料量的位元组大小 stop(非必要):如果 stop 为 true 传送请求后释放 I2C,如果 stop 为 false 传送请求后不释放 I2C,型态为 boolean,预设为 true,详见上面的描述 回传 byte:从端回传的资料量大小,单位为位元组 See also - Wire.available() […]
描述 初始化 Wire 函式库并且指明 86Duino 是主端(master)还是从端(slave)。正常来说 begin 只需要呼叫一次。 参数 address(非必要):如果 86Duino 要作为主端则不需要提供参数,如果 86Duino 要作为从端则要提供一个七位元的位址 回传 无回传值 函式库参考主页面 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.
对不起,此内容只适用于English。
对不起,此内容只适用于English。
对不起,此内容只适用于English。
对不起,此内容只适用于English。
对不起,此内容只适用于English。