hello, for my application i had to use a limit switch located 30 meters far from my microcontroller, due to the far distance i was not able to use 5vdc, can´t affort for a 24vdc power supply, i only have 220vac avaliable and so 5vdc, i have been searching information about ac voltage for MCU inputs and i found that it is possible using a diode bridge and optocoupler.
https://www.daenotes.com/elect.../PLC-programable-logic-control
have not tested yet, i need to calculate values for the input circuit diagram given, has some one ever used AC voltage for input to MCU?