[Modbus]
描述
Send a packet command to the Slave node to write to a single Coil register.
語法
node1.writeSingleCoil(write_address, value)
參數
node1
: ModbusMasterNode Object.write_address
: The address of the Coil register you want to write to.value
: The value of the Coil register to write to, usually 0 or 1.
回傳
Int: If it succeeds, send back MODBUS_SUCCESS and vice versa, send back EXCEPTION_CODE.
範例
#include <Modbus86.h> ModbusMaster bus1; ModbusMasterNode node1; uint8_t result; uint8_t led = 1; void setup() { while(!Serial); Serial1.begin(115200); bus1.begin(MODBUS_RTU, Serial1); node1.attach(16, bus1); result = node1.writeSingleCoil(5, led); if (result != MODBUS_SUCCESS) { Serial.print("writeSingleCoil => ErrorCode: "); Serial.println(result); } } void loop() {}
也可以看看
函式庫參考主頁面
86Duino 參考的文本是根據 Creative Commons Attribution-ShareAlike 3.0 License,部分文本是從 the Arduino reference 修改的。 參考中的代碼示例已發佈到公共領域。