Built-in project · no microcontroller

Up/down counter

A slide switch and a 74HC02 steer a clock into a 74HC193, which counts up or down in binary on four LEDs. There is no microcontroller in it: the simulator solves the 14 parts as a circuit, so it runs the moment you press Run, and nothing needs compiling.

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

Up/down counterlive0.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 up/down counter: a 74HC193, steered by a 74HC02.
//
// The four LEDs are the count in binary, Q3 on the left and Q0 on the right,
// stepping once a second.
//
// Click the slide switch to change direction. The 193 has two clock inputs,
// CPU (count up) and CPD (count down), and the one not in use must be held
// high. The 74HC02's four NOR gates make two OR gates:
//
//   CPU = clock OR UP_N       CPD = clock OR DOWN_N
//
// The switch pulls either UP_N or DOWN_N low. The low one lets the clock
// through to its input; the high one holds the other input high. So the
// switch picks the direction without ever touching a clock wire.
//
// Count up past 15 and it rolls over to 0; count down past 0 and it rolls
// over to 15. TCU and TCD, the carry and borrow, go low for half a clock at
// those points; wire them to a second 193's CPU and CPD for an 8-bit counter.

Parts list

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

How it is wired

17 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: Resistor, 10k Ω (1) pin 2; Resistor, 10k Ω (2) pin 2; 74HC02 quad NOR pin VCC; 74HC193 up/down counter pin PL; 74HC193 up/down counter pin VCC
  • Ground: Slide switch pin 2; 74HC02 quad NOR pin 2B; 74HC02 quad NOR pin GND; 74HC02 quad NOR pin 4B; 74HC193 up/down counter pin GND; 74HC193 up/down counter pin MR; LED, red (1) pin C; LED, red (2) pin C; LED, red (3) pin C; LED, red (4) pin C
  • Clock pin OUT; 74HC02 quad NOR pin 1A; 74HC02 quad NOR pin 3A
  • Slide switch pin 1; Resistor, 10k Ω (1) pin 1; 74HC02 quad NOR pin 1B
  • Slide switch pin 3; Resistor, 10k Ω (2) pin 1; 74HC02 quad NOR pin 3B
  • 74HC02 quad NOR pin 1Y; 74HC02 quad NOR pin 2A
  • 74HC02 quad NOR pin 2Y; 74HC193 up/down counter pin CPU
  • 74HC02 quad NOR pin 3Y; 74HC02 quad NOR pin 4A
  • 74HC02 quad NOR pin 4Y; 74HC193 up/down counter pin CPD
  • 74HC193 up/down counter pin Q1; Resistor, 330 Ω (3) pin 1
  • 74HC193 up/down counter pin Q0; Resistor, 330 Ω (4) pin 1
  • 74HC193 up/down counter pin Q2; Resistor, 330 Ω (2) pin 1
  • 74HC193 up/down counter pin Q3; Resistor, 330 Ω (1) pin 1
  • Resistor, 330 Ω (1) pin 2; LED, red (1) pin A
  • Resistor, 330 Ω (2) pin 2; LED, red (2) pin A
  • Resistor, 330 Ω (3) pin 2; LED, red (3) pin A
  • Resistor, 330 Ω (4) pin 2; LED, red (4) 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.