Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SimpleModbusSlave.h>
- #define TOTAL_REGS_SIZE 50
- unsigned int holdingRegs[TOTAL_REGS_SIZE]; // function 3 and 16 register array
- ////////////////////////////////////////////////////////////
- void setup()
- {
- randomSeed(analogRead(0));
- /*
- * arguments are:
- * baude rate
- * slave id
- * tx enable pin (not relevant on arduino)
- * max number of registers
- * low latency
- */
- modbus_configure(38400, 1, 2, TOTAL_REGS_SIZE, 0);
- }
- void loop()
- {
- for (byte i = 0; i < TOTAL_REGS_SIZE; i++)
- {
- holdingRegs[i] = (i%2 ? 1 : 0);
- }
- modbus_update(holdingRegs);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement