Built-in project · no microcontroller

ULN2803A switching four 12 V lamps

Four slide switches on a ULN2803A's inputs, four 12 V lamps on its outputs: each channel sinks its lamp to about 0.87 V. There is no microcontroller in it: the simulator solves the 9 parts as a circuit, so it runs the moment you press Run, and nothing needs compiling.

Teaching? Assign it to your class in one click.

Beginner About 15 minutes to build and run. Runs in your browser. Free, and no account needed.

The parts retail for about $8.10. On Mokxi they're free.

The circuit runs here once the page has loaded.

What you'll learn

  • Darlington arrays as low-side switches
  • Sinking current instead of sourcing it
  • Why a Darlington keeps a voltage drop
  • Switching a 12 V load from a 5 V signal
  • Difficulty: Beginner
  • Time: About 15 minutes
  • Parts: 12

How it works

The ULN2803A is eight Darlington channels in one chip. Each channel has an input B and an output C straight across from it. Here four slide switches feed four inputs, and four 12 V lamps hang off four outputs.

A switch puts 5 V or 0 V on an input. Through the input's own 2.7k resistor, 5 V is about 1.15 mA, which is enough for the channel to pull its output down to about 0.87 V. The lamp between 12 V and that output then lights with about 11.1 V.

The chip only ever pulls down. An input left in the air is off, since 7.2k inside holds it down.

Parts list

12 parts, plus the jumper wires. They retail for about $8.10; on Mokxi they're free.

Wiring table

Every connection, pin by pin, read from the circuit itself. Each row joins the pin on the left to the pin on the right, by a jumper wire or a breadboard strip.

Part and pinConnects to
Slide switch (1) pin 35 V
Slide switch (2) pin 35 V
Slide switch (3) pin 35 V
Slide switch (4) pin 35 V
ULN2803A Darlington array pin COM12 V
Filament lamp (1) pin 112 V
Filament lamp (2) pin 112 V
Filament lamp (3) pin 112 V
Filament lamp (4) pin 112 V
ULN2803A Darlington array pin GNDGround
Slide switch (1) pin 1Ground
Slide switch (2) pin 1Ground
Slide switch (3) pin 1Ground
Slide switch (4) pin 1Ground
Slide switch (1) pin 2ULN2803A Darlington array pin 1B
Slide switch (2) pin 2ULN2803A Darlington array pin 2B
Slide switch (3) pin 2ULN2803A Darlington array pin 3B
Slide switch (4) pin 2ULN2803A Darlington array pin 4B
Filament lamp (4) pin 2ULN2803A Darlington array pin 4C
Filament lamp (3) pin 2ULN2803A Darlington array pin 3C
Filament lamp (2) pin 2ULN2803A Darlington array pin 2C
Filament lamp (1) pin 2ULN2803A Darlington array pin 1C

The notes that come with it

There is no microcontroller in this one, so nothing is compiled: the simulator solves the circuit itself. The file in the editor is the notes that come with it.

sketch.ino
// A ULN2803A switched by hand: four slide switches, four 12 V lamps.
//
// The ULN2803A is eight of the ULN2003A's Darlington channels in an 18-pin
// chip: inputs 1B to 8B on pins 1 to 8, GND on pin 9, COM on pin 10, and the
// outputs 8C to 1C on pins 11 to 18, each straight across from its input.
//
// Each switch puts 5 V or 0 V on an input. Through the input's own 2.7 k
// that is about 1.15 mA, and the channel then pulls its output down to about
// 0.87 V, so the 12 V lamp between 12 V and that output lights. A ULN2803A
// only ever pulls down: the lamp goes from its supply to the output.
//
// An input left in the air is off: inside, 7.2 k holds it down.
//
// Things to try:
//   - Put a meter on an output: about 0.87 V while it is on, not 0 V. A
//     Darlington always keeps that much, which is why the lamp gets 11.1 V.
//   - COM (pin 10) is on 12 V. With lamps it does nothing; with a relay coil
//     or a solenoid it is what catches the kick when the channel lets go.

Troubleshooting

The usual mistakes with this circuit, and the fix for each.

  • A lamp never lights This project
    The lamp goes from 12 V to the output C, not to ground. The chip pulls its end down. Also check COM is on 12 V and GND is grounded.
  • An output reads 0.87 V instead of 0 V This project
    That is correct. A Darlington always keeps about that much when on.
  • The load does not turn on, or acts backwards. ULN2803A Darlington array
    The outputs sink current to ground, so connect the load between the supply and the output. A HIGH input turns the channel on. Pin 9 goes to ground.
  • Inductive loads cause spikes. ULN2803A Darlington array
    Connect pin 10 (COM) to the load supply positive when driving relays or motors, since it has clamp diodes. Without it, spikes can hurt the chip.
  • The input reads random values in one position. Slide switch
    A switch only connects or disconnects. Add a pull-up or pull-down resistor, or use INPUT_PULLUP, so the pin has a defined level when the switch is open.
  • The load never turns on when the switch is flipped. Slide switch
    Use the center (common) leg and one outer leg. The unused outer leg goes nowhere. Check that the switch is in series with the load.
  • The lamp is dim or does not light when driven from a board pin. Filament lamp
    A lamp needs far more current than a pin gives (a pin is limited to about 20 mA). Switch it with a transistor or MOSFET from its own supply that matches the lamp's voltage rating.
  • The lamp's brightness lags or it burns out the switch when it first turns on. Filament lamp
    A cold filament draws several times its running current at first. Size the switch for that surge, not just the steady current.

Change it and keep it

Open it in the editor, change the circuit or the code, and keep your version in a free account.