Codey OnlineArduino & ESP32 component library › Diode
Diode
Passive parts

Diode

Two-terminal polarized semiconductor that conducts current in only one direction (anode → cathode). Common variants: standard rectifier (1N4001-1N4007 — up to 1A, 50-1000V), Schottky (1N5817/1N5819 — low forward drop ~0.3V, fast switching), small-signal (1N4148 — fast, low current), Zener (1N4733A 5.1V, 1N4737A 7.5V, etc. — used for voltage clamping/regulation). Used as a flyback diode across inductive loads (motors, relays, solenoids), as a reverse-polarity protector, in voltage rectification, and as an OR-ing diode in power-supply combining.

Pinout — Diode

Pin Signal Description
ANODE Positive terminal — conventional current flows in here
CATHODE Negative terminal — marked with the white stripe; current flows out here

Wiring notes

2-pin POLARIZED component. Use componentId diode and put the part number (and type if non-standard) in the label, e.g. '1N4007', '1N4148', '1N5819 Schottky', '1N4733A Zener 5.1V'. Pins: ANODE (+, conducts INTO this lead) and CATHODE (-, conducts OUT of this lead — marked with the white stripe on the body). Conventional current flows ANODE → CATHODE; the diode blocks reverse current. **Flyback / freewheel diode (motors, relays, solenoids):** CATHODE to V+ (the load's positive supply), ANODE to the switched node (transistor's drain/collector). The diode shorts out the back-EMF spike that the inductor produces when current is interrupted. **Reverse-polarity protection:** ANODE to V+ input, CATHODE to circuit V+ — drops ~0.7V (use a Schottky to drop only ~0.3V). **Zener for voltage clamping:** install REVERSE-biased (CATHODE to V+, ANODE to GND) — clamps the rail to the Zener voltage.

Example wiring diagram — Diode

From To Wire
board:D4 x1:ANODE green
x1:CATHODE board:GND black

Example Arduino code — Diode

This example was written and compile-checked for the arduino-uno. Codey Online adapts it to any other supported board for you.

// Diode example for Arduino Uno
// This sketch demonstrates a diode as a simple reverse-polarity / current-direction component.
// It drives D4 HIGH, so current can flow from D4 -> diode ANODE -> diode CATHODE -> GND.

const int diodePin = 4;

void setup() {
  pinMode(diodePin, OUTPUT);
  digitalWrite(diodePin, HIGH);

  Serial.begin(9600);
  Serial.println("Diode example started.");
  Serial.println("D4 is set HIGH so current can flow through the diode from ANODE to CATHODE.");
}

void loop() {
  // Keep the output HIGH continuously.
  // If you reverse the diode, it will block current flow.
  digitalWrite(diodePin, HIGH);
  delay(1000);
}

Related components

⚙️

Ceramic Capacitor

⚙️

Electrolytic Capacitor

Linear Potentiometer (3-pin)

Linear Potentiometer (3-pin)

⚙️

Resistor

Build your Arduino or ESP32 project with AI

Describe what you want to build. Codey Online writes the code, draws the wiring diagram, compiles it and flashes your board straight from the browser.

Start for free