Linear motion detection device with Arduino

I am making a project which contains communication between two modules using nRF. I need to sense the linear motion of one end, like one of them is moving and the device should be on this movind end, where I can get data like it moves left now, right, front or back. I want to stick to arduino for operating it. Is there any package or pcb module available which can do this?

How is the device moved?

I moved your topic to an appropriate forum category @deepak_intern.

In the future, when creating a topic please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.