I'm connecting a 12V inductive limit switch for my 3d printer to a RAMPS controller (Arduino-based printer controller).

The RAMPS board operates at 5V, and connecting the 12V signal from the limit probe will surely fry the RAMPS board. A friend suggested the following circuit:

schematic and DC sweep of zener and resistor in series

As I understand it, the controlled reverse breakdown of the Zener will drop 5V from the 12V signal (and the R1 will see the other 7), and the resistor will keep the current nice and safe for the Zener (and the microcontroller?).

I don't doubt my friend, but I don't understand exactly why this is safe. Couldn't the signal short through the microcontroller and ruin my day?

Not an EE, I'm much more of a software guy. Thanks for taking a look.


2 Answers 2


Assuming that you use a 5V (or 4.7V) Zener, it should work as you described. The Zener will start to conduct at its Zener voltage, and the resistor will take up the difference (to 12V).

The only danger to the microcontroller would be if the Zener became disconnected. In that case, the full 12V would appear at the microcontroller pin. But there's a resistor in series, and digital chips have ESD diodes built-in that will stop the pin voltage exceeding Vcc (plus 0.7V or so; no problem).

I think the circuit is a good 'un.

  • \$\begingroup\$ I've been chewing on this all day. Is it correct to say that the resistance in the (broken down) Zener is low enough that it's irrelevant what the resistance is through the microcontroller to ground? I'm not certain why the Zener is the preferred path to ground instead of through the microcontroller. \$\endgroup\$ Nov 27, 2014 at 3:32
  • \$\begingroup\$ @Hovis Yes, the effective resistance of the Zener is lower than the resistance via the microcontroller. Nearly all the current flows through the Zener because it has lower resistance. \$\endgroup\$ Nov 27, 2014 at 9:23
  • \$\begingroup\$ Accepting your answer instead, because you addressed my real question. I really appreciate the schematic though, Spehro. \$\endgroup\$ Nov 28, 2014 at 20:41

It should work fine. You might want to put a resistor (a few K ohms, it's not critical) from the sensor output to ground, assuming it's a typical PNP-output. Otherwise there will be no assured "0" level at the microcontroller input.

Also, the 100K may be a bit on the high side. I'd use something more like 20K, and perhaps put a 1K in series with the input:


simulate this circuit – Schematic created using CircuitLab

The second schematic is more conservative and limits the voltage such that current into the protection diodes will not exceed a few nA under normal conditions - even with +/-100V transients at the input (but may be a few mA if a +100V transient exists and the 5V supply is not present- a value which should not result in latch-up).

An even more conservative approach is to use a BJT as follows:


simulate this circuit

This can withstand +/-100V transients and never puts a voltage outside of the supply by more than some tens of mV on the microcontroller input under any conditions.

  • \$\begingroup\$ Im trying to build a circuit that a 5v microcontroller can detect when a car ignition is turned on or off, would I be correct in saying that your circuit will work if "To PNP Output" was a 12-14v car ignition? \$\endgroup\$
    – Jay Dee
    Aug 22, 2022 at 15:40
  • \$\begingroup\$ @JayDee Yes, it should work fine in that application, and is adequately protected for a typical automotive power rail situation. \$\endgroup\$ Aug 22, 2022 at 15:44
  • 1
    \$\begingroup\$ thank you, up vote from me \$\endgroup\$
    – Jay Dee
    Aug 22, 2022 at 15:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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