Sunday 31 March 2019

How to change program for Serial 1 port on Arduino Mega?

When the Modbus object is being declared,

/**
 *  Modbus object declaration
 *  u8id : node id = 0 for master, = 1..247 for slave
 *  u8serno : serial port (use 0 for Serial)
 *  u8txenpin : 0 for RS-232 and USB-FTDI 
 *               or any pin number > 1 for RS-485
 */
Modbus slave(1,0,0); // this is slave @1 and RS-232 or USB-FTDI

You should replace it and write:
Modbus slave(1,1,0); // this is slave @1 at Serial1 and RS-232 or USB-FTDI

If you need to use Serial2 or Serial3, just put a 2 or a 3.

No comments:

Post a Comment