Help Connecting a KTR-50MM Linear Encoder to an Arduino Mega

"Hello everyone,

I am brand new to this community and I am having some trouble connecting a linear encoder KTR-50MM (https://nl.aliexpress.com/i/4000100251204.html) to an Arduino Mega board. I understand that it is a 24V sensor, so I need to step down the signal in order for it to be read by the Arduino's analog input. However, I am not sure how to do this. Despite my limited knowledge of electronics and components, I am handy with code, and I am confident that with the proper guidance I can write a program to read the encoder's output.

I've found a video on YouTube (Linear Displacement Sensor Electronic Ruler Miniature Spring Automatic Reset KTR Type 50 mm - YouTube) that talks about how to connect this encoder to an Arduino, but it doesn't make sense to me, I contacted the uploader but I didn't get any response. I don't expect anyone to just give me a solution, but I would really appreciate it if anyone could point me in the direction of some good resources or tutorials that could help me out. I have been reading the documentation for the encoder and the Arduino board, but I am not getting a clear picture of how to connect the two and how to step down the signal.

I know that there are many experienced members of this community and I would greatly appreciate any tips, recommendations or advice that you can provide me. I am willing to put in the work and I am confident that with the help of this community, I will be able to connect the encoder to the Arduino Mega board.

Thank you in advance for your help, and I look forward to learning more and contributing to this community."

It looks like it's just a linear potentiometer. Connect pins 1 & 3 to +5V and GND and pin 2 to A0 then you should be able to read the display with analogRead(A0).

Wow, that was a breeze! I guess I was making a big deal out of nothing. My main goal was to not mess anything up, like frying the sensor or board. Thanks a ton, appreciate it!

Good to hear that.
How smoothly does it work? Good, cheap linear pots are one of those things that can be hard to find.

First impressions are good. The signal doesn't jitter and is stable. The measurements look consistent at first glance. I have to check it with a dial gauge for more accuracy. So for now, it's promising.

Thanks for the feedback. I put one into my shopping cart on AliExpress!