Is the difference between mega and uno

Hi,
when I conect the sensor to arduino uno so everything works fine, the problem occurs when the same sensor with the program connect to the arduino mega nothing works. I use pin 2, does anyone know what it could be
?

(deleted)

Some pins have different functions on the MEGA and the UNO,
from my head the I2C pins are located on a different spot.