Hi, @ttalma
Welcome to the forum.
Please read the post at the start of any forum , entitled "How to use this Forum".
This will help with advice on how to present your code and problems.
A hand drawn circuit diagram will be fine.
The sensor looks like it is OPEN collector NPN.
Is the gnd of your 24V supply connected to the gnd of your UNO?
Thanks.. Tom...