Learn

The ULN2003A Darlington driver, running in a simulator

Beginner

Or see every lesson.

  • 455parts on the bench
  • 43boards running now
  • 1.00xreal time, on every board
A ULN2003A switching a 12 V solenoid from pin 13live0.000 s 0.00x
Click to open it in the editor
Blink drives 1B; the scope is on 1C: 1.08 V while the solenoid is on, 12 V while it is off, and 13.45 V for a moment as it lets go.

An Arduino pin can give about 20 mA at 5 V. A relay coil, a solenoid, a 12 V lamp or a stepper coil wants hundreds of milliamps, often at 12 V. The ULN2003A is the chip in between: seven switches in one 16-pin package, each one a Darlington pair that a pin can turn on directly.

The circuit above is the Blink sketch on an Uno. Pin 13 goes into input 1B of a ULN2003A, and a 12 V, 40 ohm solenoid hangs from 12 V down to output 1C. When pin 13 goes high, the channel pulls 1C down to 1.08 V and 0.27 A flows through the coil, which no board pin could give. The scope shows 1C dropping to 1.08 V and coming back up to 12 V every half second.

What you need

  • A ULN2003A (or a ULN2803A, eight channels) in a DIP package
  • An Arduino Uno, or any 3.3 V or 5 V board
  • A 12 V solenoid, relay, lamp or motor
  • A 12 V supply whose ground is joined to the Arduino’s
  • A breadboard and jumper wires

Wiring

Part and pinGoes toNote
ULN2003A pin 1 (1B)Arduino pin 13No resistor: the chip has its own 2.7 k
ULN2003A pin 8 (E)GNDShared with the Arduino and the 12 V supply
ULN2003A pin 9 (COM)12 VThe clamp diodes: catches the coil’s kick
ULN2003A pin 16 (1C)The solenoid’s other leadThe channel pulls this end down
The solenoid’s first lead12 VThe load goes from its supply to the output

How a ULN2003A channel works

Each channel is two NPN transistors in a row, a Darlington pair, with a 2.7 k resistor in front of its input. Put a high on the input and the pair pulls its output down to E, the common emitter, which goes to ground. The load sits between its own supply and the output, so the chip sinks current: it never puts a voltage out.

The 2.7 k is why the wiring needs no base resistor. A 5 V pin straight on the input puts in 1.15 mA, and that is plenty for the channel to sink hundreds of milliamps. A Darlington never pulls all the way to 0 V, though. It keeps about a volt, 1.08 V here at 0.27 A, so a 12 V solenoid really gets about 10.9 V. TI’s datasheet gives 0.9 V at 100 mA, 1.0 V at 200 mA and 1.2 V at 350 mA, and the simulator gives 0.905, 1.021 and 1.197 V.

The ULN2003A pinout

Hold the chip with its notch on the left. Pins 1 to 7 along the bottom are the inputs 1B to 7B, and pin 8 is E, the ground. Pins 16 down to 10 along the top are the outputs 1C to 7C, each straight across from its input, and pin 9 is COM. The ULN2803A is the same with eight channels in 18 pins: 1B to 8B on pins 1 to 8, GND on pin 9, COM on pin 10 and 8C to 1C on pins 11 to 18.

What the COM pin is for

A coil does not let its current stop at once. When pin 13 goes low and the channel lets go, the solenoid pushes its current on into 1C, and the voltage there jumps until something carries it. Every output has a clamp diode to COM inside the chip. With COM on 12 V, that diode carries the current back to the supply, and the scope shows 1C stopping at 13.45 V while the current dies away.

Take the COM wire out and run it again. Now nothing carries the current, and the output leaps past 500 V, far beyond the 50 V the chip is rated for. A real ULN2003A would break down and could be destroyed. So wire COM to the coil’s supply every time the load is a coil: a relay, a solenoid, a motor or a stepper.

From a 3.3 V board

An ESP32 or a Pico has 3.3 V pins, and they work just as well. Through the 2.7 k a 3.3 V pin puts in 0.55 mA, and the channel still sinks the solenoid’s 0.27 A with 1.09 V left across it. The chip does not care what voltage the load runs on, as long as its ground is the board’s ground.

The ULN2003 driver board

The green board that comes with a 28BYJ-48 stepper is a ULN2003A with four of its channels on a header: IN1 to IN4, power on + and -, and the motor plug’s coil pins. COM is wired to + on the board, and each output has a red LED and a 1 k resistor from +, so an LED lights while its output is pulled down. The ULN2003 board stepping its LEDs project puts the board alone on pins 8 to 11 of an Uno running the Stepper library, and the LEDs walk through the coil pattern: two on at a time, one step along at a time.

An output that is on sits at 0.68 V, and the LED takes about 2.5 mA from +. The 28BYJ-48 part in the drawer already has this board built in; the board on its own is for driving anything else that needs four sinking outputs.

Driving it from an LM393: the pull-up

A comparator like the LM393 says which of its two inputs is higher, but its output is open collector: it can pull down, and it cannot pull up. The LM393 night light project feeds an LDR divider into 1IN+ and a knob into 1IN-, set to 2.50 V, and a 10 k pull-up from the LM393’s output to 5 V makes the high. That same pull-up feeds the ULN2003A’s input, which lights a 12 V lamp.

Drag the LDR darker. At 20 lux the divider is at 2.49 V, the LM393 holds its output at 0.02 V and the lamp is off. At 15 lux the divider is at 2.70 V, the LM393 lets go, and the pull-up brings the output up to 2.26 V. It does not reach 5 V because the ULN2003A’s input draws current through the 10 k, and that is fine: the channel pulls 1C to 0.90 V and the lamp lights. Delete the pull-up and the LM393 cannot make a high at all, so the lamp never lights.

The LM311 and the LM339

The LM311 is a single fast comparator whose output transistor has both ends on pins: COL on pin 7 pulls down to EMIT on pin 1. The LM311 zero-cross project runs it on +12 V and -12 V with EMIT on ground, so it watches a sine that swings 5 V either side of ground, and still hands an Uno a clean answer: 0.004 V on every negative half, and 5 V from the Uno’s own INPUT_PULLUP on every positive one.

The LM339 is four comparators in 14 pins, and its pinout is not the LM324’s: the outputs are pins 1, 2, 13 and 14, VCC is pin 3 and GND is pin 12. Because the outputs are open collector, two of them can share one pull-up. The LM339 window comparator project wires two outputs to one LED, which lights whenever a knob is outside 1.67 V to 3.33 V. Two op-amp outputs wired together like that would fight.

What the simulation leaves out

There is no breakdown, which is why the kick without COM goes on climbing instead of destroying the chip. There is no heating and no package limit: a real DIP-16 cannot carry several channels at 350 mA for long, and here it can, so add up the currents yourself. TI publishes no model for the array’s transistors, so they are a standard 2N2222A model with one fitted number that puts the saturation on TI’s line. The comparators have no sink-current limit (a real LM393 gives out at about 16 mA) and no input common-mode limit.

Common mistakes

Wiring the load from the output to ground. The ULN2003A only pulls down, so the load goes from its supply to the output.

Leaving COM unconnected with a coil on the output. Nothing catches the kick, and the chip is the thing that breaks.

Forgetting to join the grounds. The 12 V supply’s ground, E and the Arduino’s GND must all be one ground.

Expecting 0 V on an output that is on. A Darlington keeps about a volt, so a 5 V relay on one gets about 4 V.

Leaving a comparator’s output without a pull-up. It reads low fine and never reads high.

Questions

What is the ULN2003A pinout?

Pins 1 to 7 are the inputs 1B to 7B, pin 8 is E (ground), pin 9 is COM, and pins 16 down to 10 are the outputs 1C to 7C, each straight across from its input.

Does the ULN2003 need a resistor on its input?

No. Each input has its own 2.7 k resistor inside, so an Arduino pin goes straight to it.

What is the COM pin on a ULN2003 for?

It is the common end of the clamp diodes on every output. Wire it to the supply of a coil you are switching, so the diode catches the kick when the channel turns off.

Can a 3.3 V ESP32 or Pico drive a ULN2003?

Yes. A 3.3 V pin puts about 0.55 mA into the input, which is enough for the channel to sink hundreds of milliamps.

Why does an LM393 output need a pull-up resistor?

Its output is open collector: it can pull down but cannot drive high. A resistor from the output to the reader’s supply, usually 10 k, makes the high.

Build this for real

Open the editor, change a value and watch the number move with it. Nothing to install, and no account needed.