Arduino Mega output at 2.5 Volts and how to pull-down?
I believe the problem can be solved by implementing certain changes.

Make all the GND connections common. This includes shorting both Arduino GNDs. Your floating problem will reduce significantly.
Your 2.5V reading always staying the same can imply that either that the pinMode is not set right or there is an internal short in the PCB or the circuit built.Check your perpherals connected to the board.
If there are multiple perpherals connected to your arduino mega, the current draw is more than the threshold. So technically your signal acts abnormally by fluctuating the signal strength in the circuit.
Rearrange your code initialization, functions, setup and loop statements, figure where the loop does not work according to your requirement.
To prove a point, try giving output of your mega from other pin than just 51. Check if the problem still exists.

These are the things I can think of from the top of my head right now. Hope this helped.