I have an inductance sensor on a CNC machine that goes 12 V high when triggered (open collector when not). I want to read that input on my Arduino which uses 5 V logic.

I was thinking I could just use a simple NPN transistor to do the logic level shifting. Would this work? I don't want to test it in case it could fry the Arduino.


2 Answers 2


It will work. This circuit should be at logic 1 if there is no signal and at logic 0 if there is 12V signal present.

12V --|10K|----|
            |   \
            -    >
           | |    |
           | |   ---
            -     -

P.S. 10K resistors are just there as a generic value. For this purpose you can use almost anything. Base-ground resistor is 100K as recommended by @Russell.

  • 5
    \$\begingroup\$ Add a 100k from base to ground 'for safety' - especially so when input can be open circuit. Without this, transistor leakage can turn the transistor on when the input is open circuit. With 100k base to ground leakage current would need to make Vbe > say 0.4V to start to have any turn of effect. So i=V/R = 0.4/100k = 4 UA.Not much, but as long as it is less than that all should be well. \$\endgroup\$
    – Russell McMahon
    Mar 15, 2012 at 4:59

If you only need to read from the sensor, I'd suggest a simple voltage divider instead.

Hook the sensor up to ground with 3 10k resistors in series in between. hook your arduino up in between the 2nd and 3rd resistor and you are done.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.