High voltage to TTL conversion
Here's the LTspice schematic, with the code following it if you want to play with the circuit. R1, R2, and R3 are used instead of a single resistor because of the maximum voltage allowed across a single resistor, something like 150V peak.

Check the voltage spec's of the resistors you want to use and make sure it won't be exceeded regardless of the input voltage or the tolerances of the resistors.



Version 4
SHEET 1 2680 692
WIRE -672 -2176 -1440 -2176
WIRE -576 -2176 -672 -2176
WIRE -672 -2144 -672 -2176
WIRE -672 -2032 -672 -2064
WIRE -576 -2032 -672 -2032
WIRE -672 -1984 -672 -2032
WIRE -1280 -1936 -1344 -1936
WIRE -1152 -1936 -1200 -1936
WIRE -1024 -1936 -1072 -1936
WIRE -880 -1936 -944 -1936
WIRE -800 -1936 -880 -1936
WIRE -736 -1936 -800 -1936
WIRE -1440 -1872 -1440 -2176
WIRE -1344 -1872 -1344 -1936
WIRE -880 -1872 -880 -1936
WIRE -800 -1872 -800 -1936
WIRE -1440 -1744 -1440 -1792
WIRE -1344 -1744 -1344 -1792
WIRE -1344 -1744 -1440 -1744
WIRE -880 -1744 -880 -1808
WIRE -880 -1744 -1344 -1744
WIRE -800 -1744 -800 -1792
WIRE -800 -1744 -880 -1744
WIRE -672 -1744 -672 -1888
WIRE -672 -1744 -800 -1744
WIRE -576 -1744 -672 -1744
WIRE -1440 -1680 -1440 -1744
FLAG -1440 -1680 0
FLAG -576 -2176 MCU_Vcc
FLAG -576 -2032 MCU_I/O
FLAG -576 -1744 MCU_GND
SYMBOL res -1184 -1952 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R1
SYMATTR Value 1Meg
SYMBOL npn -736 -1984 R0
SYMATTR InstName Q1
SYMATTR Value 2N3904
SYMBOL res -688 -2160 R0
SYMATTR InstName R4
SYMATTR Value 10k
SYMBOL res -816 -1888 R0
SYMATTR InstName R5
SYMATTR Value 10k
SYMBOL voltage -1344 -1888 R0
WINDOW 3 24 96 Invisible 2
WINDOW 123 0 0 Left 2
WINDOW 39 0 0 Left 2
SYMATTR InstName V1
SYMATTR Value PULSE(0 400 1 1ms 1ms 100ms)
SYMBOL diode -864 -1808 R180
WINDOW 0 24 64 Left 2
WINDOW 3 24 0 Left 2
SYMATTR InstName D1
SYMATTR Value 1N4148
SYMBOL voltage -1440 -1888 R0
WINDOW 123 0 0 Left 2
WINDOW 39 0 0 Left 2
SYMATTR InstName V2
SYMATTR Value 5
SYMBOL res -1056 -1952 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R2
SYMATTR Value 1Meg
SYMBOL res -928 -1952 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R3
SYMATTR Value 1Meg
TEXT -1426 -1712 Left 2 !.tran 2 startup uic