Hi Wayne:
The ModBus program that runs on an Arduino does not utilize Ports and Pins in Mach3. It is a totally separate operation.
1. The ModBus program uses registers, beginning with 0 up to I believe 48.
2. These registers are scanned by the Serial ModBus Configuration in Mach3.
3. You verify the register is being read by the "Test" window in the Serial ModBud Config page;
4. When the action is working i.e., seeing the pot value change, or a button push change from a 0 to a 1,
5. You can then write a "Brain" which reads the register, which activates a Mach3 OEM code, i.e. Cycle Start, FeedHold etc.
Zafar posted a PDF file, showing how to setup (2) potentiometers for Feedrate ovr., and Spindle %.
The ModBus program uses the Arduino language format to set pins as input, output, or analog read/write, in void(setup).
Each Arduino pin has a corresponding ModBus "register", in the void(loop).
You need to use the Arduino format to setup the ModBus program. Log onto the Arduino site, and study the examples.
On the Arduino board, pins 0 and 1 are Serial Rx, and Tx. Pins 2 through 12 are digital I/O, and pins A0 through A5 are analog I/O.
The Mega has (4) Serial ports, 15 analog pins, and 42 digital I/O.