Arduino RS485 serial communication problem

Please use code tags when posting code. Please edit your post
Type
** **[code]** **
before the code
Type
** **[/code]** **
after the code

Please make a simple diagram how everything is connected; a photo/scan of a hand-drawn one is fine and far better than a description that can be misunderstood.

You're using a Mega with three additional serial ports; wire the RS485 to e.g. the pins for Serial1 and use Serial1 (Serial1.write, Serial1.print, Serial1.available, Serial1.read, ...) for the communication over the RS485 bus and the Serial for communication with the PC.