Projects / Diode and LED curve tracer

Diode and LED curve tracer

Intermediate2.5 hGuided buildReviewed

Build it step by step

0 of 7 done
  1. NANOMCP4725LM35823.3°C

    Wire the DAC and op-amp

    Check the follower with a meter.

  2. NANO

    Add the resistor

    100 ohm to ground.

  3. NANO

    Sweep a 1N4148

    Print the points.

  4. NANO

    Plot the curve

    Voltage against current.

  5. NANO11.2 mA

    Try a red LED

    Compare the knee.

  6. NANO

    Try a different colour

    Higher knee.

  7. NANO

    Mark the knees

    On the plot.

In short

How do you build a diode and LED curve tracer?

An Arduino sweeps a voltage across a diode and plots its I-V curve on the serial plotter. You need Arduino Nano, MCP4725 12-bit DAC module, Resistor 100 Ω, LM358 Op-Amp, LED 5 mm red and Signal Diode 1N4148. It takes 7 steps and about 150 minutes.

Level
Intermediate
Time
About 150 min
Parts
6

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
MCP4725 VCC, GNDNano 5V, GNDPower
MCP4725 SDA and SCLNano A4 and A5I2C
MCP4725 OUTLM358 pin 3Sweep voltage
LM358 pin 2LM358 pin 1Makes it a voltage follower
LM358 pin 8 and pin 4Nano 5V and GNDPower
LM358 pin 1 (output)Diode anode, and Nano A0Voltage applied
Diode cathode100 ohm resistor to GND, and Nano A1Current sense node

Code

A diode does not obey Ohm's law: it passes almost nothing until the voltage across it reaches about 0.6 V for silicon or about 1.8 V for a red LED, and then the current rises very quickly. A curve tracer shows this by stepping a voltage upward, measuring the current at each step and plotting one against the other. The DAC makes the voltage, the op-amp buffers it so the DAC is not loaded, and the 100 ohm resistor turns the current into a voltage the Nano can read: current is that voltage divided by 100. Compare a 1N4148, an LED, and if you have one a Schottky diode, and you will see each knee at a different voltage. Put the part in the right way round, anode on the op-amp side, or it will show no current. The sweep stops at 20 mA, which is safe for a small LED and does not overload the op-amp; never use a larger LED or a power diode on this circuit. Arduino IDE, board "Arduino Nano" (try the Old Bootloader option if the upload fails).

Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

// Diode and LED curve tracer: sweeps 0 to 3.3 V through the part and a 100 ohm resistor, then prints voltage across the part and current as CSV.
// Library: Adafruit MCP4725. Board: Arduino Nano. Open the Serial Plotter or copy the output into a spreadsheet.
// Keep the sweep at 3.3 V or less, and stop below 20 mA: the op-amp cannot supply more.
#include <Wire.h>
#include <Adafruit_MCP4725.h>
Adafruit_MCP4725 dac;
const float R = 100.0;                         // sense resistor in ohms
const float VCC = 5.0;
float readV(byte pin) { long s = 0; for (int i = 0; i < 16; i++) s += analogRead(pin); return (s / 16.0) * VCC / 1023.0; }
void setup() {
  Serial.begin(115200);
  dac.begin(0x60);
  dac.setVoltage(0, false);
  delay(500);
  Serial.println("Fit the part: anode to the op-amp side. Press Enter to sweep.");
  while (!Serial.available()) {}
  while (Serial.available()) Serial.read();
  Serial.println("volts_across_part,milliamps");
  for (int code = 0; code <= 2700; code += 20) {        // 2700 of 4095 is about 3.3 V
    dac.setVoltage(code, false);
    delay(30);
    float top = readV(A0), bottom = readV(A1);
    float vd = top - bottom;
    float ma = bottom / R * 1000.0;
    Serial.print(vd, 3); Serial.print(','); Serial.println(ma, 2);
    if (ma > 20.0) break;                                // protect the op-amp and the part
  }
  dac.setVoltage(0, false);
  Serial.println("Done.");
}
void loop() {}

What the serial monitor should show

Open the serial monitor at the baud rate in the code. This is what our simulator prints for a virtual Arduino Nano with its sensors at their default values. Your numbers will follow your real readings, but the format should match.

Fit the part: anode to the op-amp side. Press Enter to sweep.

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
1N4148Knee near 0.6 V
Red LEDKnee near 1.8 V
Reverse the partAlmost no current
Sweep endStops at 20 mA at most

If it does not work

No current

Reverse the part.

Curve is noisy

Average more readings.

Output stops rising

The op-amp limits near 3.5 V; stay below that.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the diode and LED curve tracer?

Arduino Nano, MCP4725 12-bit DAC module, Resistor 100 Ω, LM358 Op-Amp, LED 5 mm red and Signal Diode 1N4148.

How long does the diode and LED curve tracer take to build?

About 150 minutes for a intermediate maker, in 7 steps.

How do I know the diode and LED curve tracer works?

1N4148: Knee near 0.6 V. Red LED: Knee near 1.8 V. Reverse the part: Almost no current.

No current: what should I check?

Reverse the part.

Curve is noisy: what should I check?

Average more readings.

Output stops rising: what should I check?

The op-amp limits near 3.5 V; stay below that.