sendBit()

Description

Sets the arguments as bits to the private array writeData in the ModbusMasterNode class and automatically stacks the data, using beginTransmission with writeMultipleCoils without parameters. writeData is the content of a Modbus packet using the Write function code.

Syntax

node1.sendBit(value)

Parameters

node1: ModbusMasterNode object.

value: Fill in the Boolean value of the writeData array, i.e. the content of the Modbus packet to be sent.

Example

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

#include <Modbus86.h>

 

ModbusMaster bus1;

ModbusMasterNode node1;

 

uint8_t result;

 

void setup()

{

    while(!Serial);

    bus1.begin(MODBUS_RTU, Serial1);

    node1.attach(16, bus1);

 

    node1.beginTransmission(5);

    node1.sendBit(true);

    node1.sendBit(false);

    result = node1.writeMultipleCoils();

 

    if (result != MODBUS_SUCCESS) {

        Serial.print("ErrorCode: ");

        Serial.println(result);

    }

}

 

void loop()

{

}

See Also

beginTransmission()
writeMultipleCoils()


Library Reference

The text of the 86Duino reference material follows the Creative Commons Attribution-Share Alike 3.0 License. The code examples in the reference material have been released into the public domain.