motion sensor is wrong work!

Hello there.

I replace my phone memory ram(32 g) because have error 4013 (red screen).

but after this motion screen is wrong work.i mean when i rotate phone to the left phone screen rotate to the right! i dont know why! i try reset factory-restore- force restart-and somethings like this but doesn’t worked.anyone can help me plz???

crwdns2934089:0crwdne2934089:0 crwdns2934093:0crwdne2934093:0

crwdns2934109:0crwdne2934109:0

crwdns2889612:0crwdne2889612:0 0
crwdns2934285:0crwdne2934285:0