Hello, I have a question related to a level crossing in a train layout. When the barriers are up or down, the signal to stop the motor is a tension of 12 V (the same as the input). I want to control it through an arduino. This means that I have to convert the 12 v to the 5 v for a digital input in the Arduino. Any advise?
If I were doing that, the most robust way to handle it is with a Logic Optocoupler. You can use the internal pullup of the Arduino and about 1K series resistor for your 12V input to the diodes. Tie the emitter to Arduino ground, the collector to the input you are using.
That allows you to isolate your Arduino from your train. You didn't mention whether the train uses AC or DC, with this device it doesn't matter.