smarmengol / Modbus-Master-Slave-for-Arduino

Modbus Master-Slave library for Arduino
GNU Lesser General Public License v2.1
473 stars 328 forks source link

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

Closed ronie19 closed 4 years ago

ronie19 commented 5 years ago

If I want to change serial port to Tx1, Rx1 or pin 19 and 18 on Arduino Mega other than default port then how can it be done? The arduino device is going to be a slave device. Kindly guide the changes to be made.

smarmengol commented 5 years ago

Dear Ronie19,

When the Modbus object is being declared,

/**

You should replace it and write:

Modbus slave(1,1,0); // this is slave @1 and RS-232 or USB-FTDI

This second 1 is the Serial1 port. If you need to use Serial2 or Serial3, just put a 2 or a 3. Regards,