High level logic level
Use this optocoupler configuration to read the logic level:



You need to adjust the resistor labelled 5K to 10K in order to get best results. If you are getting logic HIGH on small voltage like 5-10V then increase the resistor (you are free to go beyond 10K as well). If you not getting logic HIGH at 20-25V, then reduce the resistor value.

On the output side, RC filter has been used to smooth out any fluctuations you might have introduced on the input side. You won't need debounce on the code side.

Besides giving you a nice logic level for arduino, this will also save your arduino from receiving 30V directly in case something goes wrong.