Add 3.5mm Jack to Raspberry Pi for TTL Signal with 5V
Try this circuit. You can use most common NPN general purpose transistors, the editor defaults to 2N3904, but 2N2222 or BC848 will work.






simulate this circuit &ndash; Schematic created using CircuitLab