# Are diodes backwards?

So I've been learning about diodes (since I don't have an electrical background).

Technically, current flows from the negative side to the positive side (electron current flow).

However, a diode allows a flow from the + to the - side (forward bias) and disallows a flow from the - side to the + side (reverse bias).

So, let's say I want to protect the GPIO pin on a raspberry pi (this would be the + side) and have a diode, then a circuit and in the end, connected to a ground pin (-).

How can the diode protect the GPIO pin, when the current actually comes for the negative side to the positive side? It makes more sense to think that the electricity within a diode can flow from the positive to the negative side, in order to protect the positive side. The ground (- side) is less important (or is this wrong?).

How can a diode allow electricity to flow from the + side to the - side, while electron flow is the opposite?

Is my thinking wrong?

Edit: the following schematic shows where I can see a contradiction and what I am confused about.

simulate this circuit – Schematic created using CircuitLab

• Don't confuse 'conventional current flow' (like drving on the left), which is how diodes, and everything else, is described, and electron flow (driving on the right), which an opposite way of doing things. If you and everybody else sticks with one convention, you and they will be happy. If you switch from one to the other mid argument, then you will get crashes and bent metal. Putting aside which convention is 'more correct', there are so many road signs and road markings on the conventional current side that switching to the electron flow would be infeasible. Stay conventional. – Neil_UK Nov 20 '16 at 21:32
• That's not a protection diode! At least, it serves no useful purpose, and is in a different place to where engineers would put a protection diode. – Neil_UK Nov 20 '16 at 21:36
• @Neil_UK I think I put the wrong one with the editor.. I meant something like a 1N4004 :/. - Edited the schematic. – Kevin Van Ryckegem Nov 20 '16 at 21:37
• It doesn't matter what type of diode you put in that position, it's not a protection diode, and it serves no useful purpose. – Neil_UK Nov 20 '16 at 21:38
• No. First, specify what fault conditions you want your circuit protected from, then put components in the right place to do that. Do you know what fault conditions the term 'protection diode' when used by electrical engineers is designed to protect against? – Neil_UK Nov 20 '16 at 21:40

Do you mean this circuit? U1 is the Raspberry, $R_p$ is the internal pullup the GPIO pin shown has.

simulate this circuit – Schematic created using CircuitLab

This works as follows: When the switch is open or connects the circuit to a voltage higher than 3.3V, the diode is non-conducting. This means the GPIO is internally tied to 3.3V by $R_p$. When in contrary the switch connects the circuit to 0V, the diode is conducting and there is current flowing from the Raspberry GPIO to ground. The GPIO internal potential is a bit above GND because of the diode voltage drop and the outer resistor, but still detectable as low.

The outer 1kΩ resistor is for the case you accidentally configure your GPIO as an output and set it to high. It limits the current to ~3mA then.

• The schematic made me realize I am wrong and as long as I am consistent, everything does check out! I was mixing the conventional flow with the electron flow, since the diagrams are usually made using the conventional flow. If I understand it well, the diode protects that the + remains the + and the - remains the -, no matter the differences in voltages. – Kevin Van Ryckegem Nov 20 '16 at 21:57
• '... since the diagrams are usually made with conventional flow ...' Er, no!. The diagrams are always made with conventional flow. Always. Schematics use conventional flow. Diodes are marked for conventional flow. Ammeters are marked for conventional flow. Spice (any flavour) uses conventional flow. The only people who use electron flow at the circuit level are noobs who have just discovered the concept, and are on the ways to confusing themselves. People who design the actual transistors (and solid state physics students) use electron flow, but they also use hole flow as well. – Neil_UK Nov 21 '16 at 6:12

Electron flow and conventional current flow are opposite ways around. The reason for this is very simple; when the convention was set up, nobody knew about electrons at all (J J Thompson discovered them later on) let alone which way they went. But it was clear that electricity had a polarity, and so a plus and minus were chosen which, it turned out, were opposite to the actual direction electrons go in. And everyone by that point had been using the conventional polarity for a very long time, and it usually doesn't matter to anyone but physicists, so the wrong-way-roundedness was kept as the convention.

The diode in the circuit would protect the Pi from somebody putting the batteries in the wrong way round. That's about it.

It's not really clear what you intend the diode to do, but one misconception is obvious.

Current is the flow of charges. By convention, electrons are negative. Electrons therefore flow in the opposite direction of current.

However, forget electron flow and think only of current. That goes out the positive terminal of a battery (when not being charged), and back in the negative input. A diode is a one-way valve for current. Current can go in the anode and out the cathode, but not the other way around.