Built-in project · no microcontroller

LM324 four-LED bar graph

Four comparators in one LM324 against a 1, 2, 3 and 4 V resistor ladder: turn the knob and four LEDs light one by one, no microcontroller. There is no microcontroller in it: the simulator solves the 15 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.

Intermediate Runs in your browser. Free, and no account needed.

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

LM324 four-LED bar graphlive0.000 s 0.00x
Click to open it in the editor
The circuit itself, running here on the simulator. Press what can be pressed; click anything else to open it in the editor.

How it works

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
// An LM324 bar graph: four comparators in one chip, four LEDs.
//
// The LM324 is four of the LM358's op-amps in a 14-pin chip, on the same
// single supply. Here each one is a comparator with no feedback. All four +
// inputs are on the knob's wiper. The four - inputs are on a ladder of five
// 10 k resistors from 5 V to ground, which taps off 1 V, 2 V, 3 V and 4 V:
//
//   amplifier 1 (pin 2)   1 V      amplifier 3 (pin 9)    3 V
//   amplifier 2 (pin 6)   2 V      amplifier 4 (pin 13)   4 V
//
// Each output goes high, and lights its LED, once the knob is above its tap.
// Turn the knob up from 0 V and the LEDs come on one by one: one past 1 V,
// two past 2 V, three past 3 V and all four past 4 V. This is how the level
// meters on old stereos were made.
//
// Mind the supply pins. On an LM324 they are not on the corners: VCC is
// pin 4 and GND is pin 11.

Parts list

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

How it is wired

15 connections, pin by pin, read from the circuit itself. Each line is one set of pins joined together, by a jumper wire or a breadboard strip.

  • 5 V: Potentiometer pin 1; LM324 quad op-amp pin VCC; Resistor, 10k Ω (1) pin 1
  • Ground: Potentiometer pin 3; LM324 quad op-amp pin GND; Resistor, 10k Ω (5) pin 2; LED, green (1) pin C; LED, green (2) pin C; LED, yellow pin C; LED, red pin C
  • Potentiometer pin 2; LM324 quad op-amp pin 1IN+; LM324 quad op-amp pin 2IN+; LM324 quad op-amp pin 3IN+; LM324 quad op-amp pin 4IN+
  • LM324 quad op-amp pin 1OUT; Resistor, 220 Ω (1) pin 2
  • LM324 quad op-amp pin 1IN-; Resistor, 10k Ω (4) pin 2; Resistor, 10k Ω (5) pin 1
  • LM324 quad op-amp pin 2IN-; Resistor, 10k Ω (3) pin 2; Resistor, 10k Ω (4) pin 1
  • LM324 quad op-amp pin 2OUT; Resistor, 220 Ω (2) pin 1
  • LM324 quad op-amp pin 3OUT; Resistor, 220 Ω (3) pin 1
  • LM324 quad op-amp pin 3IN-; Resistor, 10k Ω (2) pin 2; Resistor, 10k Ω (3) pin 1
  • LM324 quad op-amp pin 4IN-; Resistor, 10k Ω (1) pin 2; Resistor, 10k Ω (2) pin 1
  • LM324 quad op-amp pin 4OUT; Resistor, 220 Ω (4) pin 2
  • Resistor, 220 Ω (1) pin 1; LED, green (1) pin A
  • Resistor, 220 Ω (2) pin 2; LED, green (2) pin A
  • Resistor, 220 Ω (3) pin 2; LED, yellow pin A
  • Resistor, 220 Ω (4) pin 1; LED, red pin A

Change it and keep it

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