Author Options:

Help with zener diodes? Answered

I'm trying to get a better grasp on how to use a zener diode.

I have plenty of information about what they do (allow current to flow one way until the voltage is high enough, then reverse the flow), how they work and even how they are made, but finding basic information about how to use it is harder.

I am trying to connect a Keyboard Encoder to an Arduino. The Encoder runs on 3.5v and the Arduino runs on 5v.
When a pin on the Encoder is connected to ground it outputs a keystroke to the computer.

I have an Arduino pin set to HIGH (5v) as normal and under some conditions it changes briefly to LOW (ground) which is when I want the Encoder to output to the PC, and then back to HIGH (5v) again.

To protect the encoder from the higher voltage coming from the Arduino I think I need to use a zener diode. If my understanding is correct it should work as described in the diagram.

When the Arduino pin is High (5v) the Encoder reads as 3.5v and any voltage over 3.5v is drained to ground rather than pushing against the Encoder. No keystroke is passed.
When the Arduino pin is LOW (0v) the Encoder reads 0v, the zener diode adds resistance and voltage runs to the Arduino. The Encoder sends a keystroke to the PC.

My main concern is that once the voltage is over the 3.5v all of the power will drain to ground rather than maintaining the 3.5v before the zenner diode. I can't find anywhere which will tell me either way.

If you need more information on my set up please let me know. I'm really struggling to get my head around this!


The forums are retiring in 2021 and are now closed for new topics and comments.

Best Answer 7 years ago

Not quite since the arduino will be pushing 5V into the encoder. A Zener Diode isn't what your looking for.

For one the stripe on the diode indicates the Cathode or side that is typically connected to ground. Secondly the diode would allow the 3.5V to flow from it's anode to its cathode. If a higher voltage tries to come from the cathode to the anode it will be blocked unless it's over the diode's threshold. If the diode's threshold is around 5 volts and that 5V is coming from the cathode side it will be allowed through to the anode side.

What your looking for is a relay or transistor switch. A 5V relay may be the easiest solution. As long as the relay is receiving the 5V signal from the Arduino it will stay flipped to one set of contacts, not allowing the 3.5V signal from the encode to trigger a key stroke. When the Arduino pin gets pulled to ground the relay flips to the other set of contacts allowing the 3.5V signal from the encoder to go on through to the PC.


7 years ago

Several choices.
1.) Mod the Arduino to run on 3.5 volts (they're happy to do that)
2.) Check the encoder's specification, you may find its "5V tolerant"
3.) Use a "bidirectional level translator", like this one http://www.ti.com/lit/ds/sces727/sces727.pdf unfortunately, like most modern silicon its only available in surface mount
4.) Just TRY adding two resistors in series between arduino and encoder, say 1K each, and put the zener in the middle as you have shown. It won't be very fast, but it might just work.

A relay won't work


Answer 7 years ago

Good suggestions.

1) I need the Arduino running at 5v for other operations, but for other projects that could be a great solution. I guess there are probably 'ibles for how to do that, if not it should be easily found on Google.

2) I can't find much documentation for the encoder, I think it should be 5v tolerant, but if I can easily work around it then I would rather do that.

3) Interesting, but not really suitable for this project.

4) Also interesting, but I want it to operate as fast as I can, so probably not.

Why wouldn't a relay work here?
I'm not looking at using a mosfet for the job. I've played with those enough to be confidant with what I'm doing there. Always trying to learn more though (which is why I was thinking zener diode).


Answer 7 years ago

Relay's nothing like fast enough.
4.) maybe fast enough, and a lot faster than a relay.

Put a link to the encoder datasheet and lets see what it says.