Built-in project · no microcontroller

NAND latch

Two cross-coupled 74HC00 gates hold one bit, and a slide switch sets and resets it. There is no microcontroller in it: the simulator solves the 8 parts as a circuit, so it runs the moment you press Run, and nothing needs compiling.

IntermediateRuns in your browser. Free, and no account needed.

NAND latchlive0.000 s 0.00x
Hold the button
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 SR latch: two NAND gates that hold each other's answer.
//
//   Q    = NAND(set,   Qbar)
//   Qbar = NAND(reset, Q   )
//
// Both inputs are active low and sit at 5 V through their pull-ups. Flip the
// slide switch: the pole is grounded, so it pulls one input down, that gate's
// output goes high, and the other gate (seeing a high on both inputs) goes
// low and feeds that back. Let the input go and nothing moves: each gate is now
// holding the other one where it is. That is one bit of memory, and it is the
// same cell that is inside a static RAM.
//
// It is also the standard cure for switch bounce. A mechanical contact chatters
// for a few milliseconds when it closes; the latch flips on the first edge and
// then ignores every one after it, because the input it is bouncing on is no
// longer the one deciding anything.

Parts list

10 parts, plus the jumper wires. Every one is in the editor's parts bin.

How it is wired

8 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: 74HC00 quad NAND pin VCC; Resistor, 10k Ω (1) pin 2; Resistor, 10k Ω (2) pin 2
  • Ground: Slide switch pin 2; 74HC00 quad NAND pin GND; LED, green pin C; LED, red pin C
  • Slide switch pin 1; 74HC00 quad NAND pin 1A; Resistor, 10k Ω (1) pin 1
  • Slide switch pin 3; 74HC00 quad NAND pin 2A; Resistor, 10k Ω (2) pin 1
  • 74HC00 quad NAND pin 1B; 74HC00 quad NAND pin 2Y; Resistor, 220 Ω (2) pin 1
  • 74HC00 quad NAND pin 1Y; 74HC00 quad NAND pin 2B; Resistor, 220 Ω (1) pin 1
  • Resistor, 220 Ω (1) pin 2; LED, green pin A
  • Resistor, 220 Ω (2) pin 2; 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.