What will happen if the diode is connected in the wrong direction when wiring the membrane switch?
In the matrix circuit of a membrane switch, reversing the direction of the diodes is a very common but serious assembly error. The specific impact depends on the extent of the reversal (whether it is for individual diodes or all of them) and the scanning method.
The Role of Diodes in Membrane Switches
In matrix circuits, each key is connected in series with a diode (typically 1N4148), the main function of which is to prevent "ghosting" - when multiple keys are pressed simultaneously, the current may "go around" through the parasitic circuit, causing the MCU to mistakenly interpret an unpressed key as being pressed.
The unidirectional conduction characteristic of the diode ensures that the current can only flow in the scanning direction, blocking the reverse crosstalk path.
The consequences of reversing (something)
All the diodes are connected in the wrong direction.
The entire matrix is completely non-functional. This is because the scanning logic of the MCU is designed based on the direction "current from the output terminal → key → diode → input terminal". Once all the diodes are reversed, the current is completely blocked, and all key presses have no response.
Single/diode connected in reverse polarity
The manifestation is more concealed, and the symptoms include:
This button is completely malfunctioning: when pressed, the MCU fails to detect any level change (the most common issue).
Other buttons trigger incorrectly: reverse diodes form abnormal conducting paths under certain key combinations, causing "ghost keys" to appear instead.
Multiple key conflicts occur abnormally: some combinations of keys work properly while others fail, resulting in unpredictable behavior.
Firmware configuration does not match the hardware orientation: if the diode orientation is ROW2COL but the firmware configuration is COL2ROW (or vice versa), it may cause partial key failures, or even prevent the entire matrix from functioning.
The correct directions under the two scanning methods
The direction of the diode must be strictly corresponding to the scanning method:
COL2ROW (The most common, default in QMK)
Scanning logic: Column pin outputs low level → Key → Diode → Row pin input (with pull-up)
Diode direction: Anode connected to column side (key side), cathode (with color ring/marked end) connected to row line
Memory aid: "COL2ROW = Cathode to ROW"
Column (output low) ── Button ── | > | ─── Row (input pull-up)
Anode Cathode
ROW2COL (less commonly used)
Scanning logic: Output low level on row pin → Key → Diode → Column pin (with pull-up)
Diode direction: Anode connected to row side (key side), cathode (with color ring/marked end) connected to column line
Row (output low) ── Button ── | > | ─── Column (input pull-up)
Anode Cathode
How to determine if the direction of a diode is correct
Look at the mark.
Through-hole diode (1N4148, DO-35 package): The black color ring terminal on the glass tube is the cathode
Surface mount diode (SOD-123/SOD-323): The wire-marked terminal at the top of the component is the cathode
Multimeter test
Using the diode setting for measurement:
Connect the red probe to the anode and the black probe to the cathode → Display 0.5 - 0.7V (conducting)
Reverse the probe connections → Display OL/overload (cut-off)
Compare firmware configuration
Check whether the "DIODE_DIRECTION" definition in the firmware is consistent with the actual soldering direction on the PCB:
#define DIODE_DIRECTION COL2ROW → Cathode connected to row
#define DIODE_DIRECTION ROW2COL → Cathode connected to column
The repair method for reversed connections
Through-hole diode: Heat the solder joints at both ends with a soldering iron, then remove and flip 180 degrees for re-welding.
Surface-mount diode: Heat with a hot air gun and flip, or re-weld one more time.
Verification after repair: Use a multimeter's diode setting to confirm the direction for each diode, and then conduct a full matrix key test.
How to prevent reverse connection
| Prevention measures | Specific practices |
| PCB silk-screen marking | Print a diode symbol (▶ —) beside the pad, with the arrow pointing towards the cathode |
| Polarity marking uniformity | The color bands/lines of all diodes are marked in the same direction (for example, all pointing to the right) |
| Pre-weld inspection | Use a multimeter to randomly test 5 to 10 pieces to confirm the direction. |
| AOI inspection | During batch production, automatic optical inspection (AOI) is used to verify polarity. |
| First piece test | After welding is completed, a full matrix scan test is conducted first to ensure that all buttons are functioning properly before proceeding with mass production. |
💡 Summary: The consequence of connecting the diode in reverse is that individual keys may malfunction, or in severe cases, the entire matrix may completely fail to function. The fundamental cause is that the unidirectional conduction direction of the diode does not match the scanning direction of the MCU, resulting in the interruption of current or the generation of abnormal conduction paths. The solution is to confirm the scanning method (COL2ROW or ROW2COL), ensure that the cathode (color ring/terminal marked) of all diodes is facing the correct direction, and after welding, verify each diode one by one using a multimeter.
