hi,
pls read this when you are placing lots of code
did you see the edited picture … youre wiring is wrong for the mega