Skip to content
digiwleeaTools
LearnGlossaryAboutCheat sheetHow a CPU worksToolsOpen the lab →

Binary clock circuit: BCD hours and minutes, live

A binary clock shows the time in binary-coded decimal: each decimal digit of HH:MM gets its own column of bits, so 13:47 reads 01, 0011, 100, 0111. This live clock counts real BCD hours and minutes from 00:00 to 23:59 and back to 00:00, one minute per tick of its clock.

To read it, take each column on its own and add up the weights of its lit bits, 8, 4, 2 and 1 from the top: HT (hours tens, 2 bits, 0 to 2), HO (hours ones, 4 bits, 0 to 9), MT (minutes tens, 3 bits, 0 to 5) and MO (minutes ones, 4 bits, 0 to 9). Inside, four BCD digit counters share one clock, so every digit changes on the same edge: MO counts every tick and wraps from 9 to 0; MT moves on when MO is 9 and wraps from 5 to 0; and the hours move on when the minutes read 59. The hours have to be one counter, not two, because their ones digit normally wraps at 9 but at 23 both hour digits go back to 0 together. Each flip-flop's next value is a minimal sum of products of its digit's enable and bits, found with the Quine-McCluskey method using the codes a digit never shows (MO above 9, MT above 5, hours past 23) as don't-cares, each digit a close relative of the decade counter. A real binary clock adds a seconds pair (another 0 to 5 and 0 to 9 digit) and divides a crystal down to one tick per second, for example with a CD4060, whose 14 stages turn 32,768 Hz into 2 Hz. Here each tick is a minute, so you can watch the hours change. The live clock opens with CLR high (00:00); set CLR to 0 and it starts counting. Before the page is built, 130 minutes are checked on all 13 outputs on the running clock, and the whole day, every minute from 00:00 through 23:59 and back to 00:00, has been checked with the clock stepped by hand.

Big circuit: pinch, scroll or tap + to zoom in, then drag to move around.

Live circuit: click the inputs to toggle them and watch the outputs update. It runs the real simulator, right here on the page.

Open this circuit in the lab →

What you need

Step by step

  1. Place a clock CLK, an input CLR, and probes HT1 HT0, HO3 to HO0, MT2 to MT0 and MO3 to MO0.
  2. Build the minutes ones as a BCD counter on CLK: 0 to 9 and back to 0.
  3. Build the minutes tens as a 0-to-5 counter that only moves when the ones digit is 9.
  4. Build the hours as one counter from 00 to 23 that moves when the minutes read 59. Clear, then let it run: 00:59 is followed by 01:00, and 23:59 by 00:00.

Reading the time

TimeHTHOMTMO
00:000000000000000
09:590010011011001
10:000100000000000
13:470100111000111
23:591000111011001

Each column is one decimal digit in BCD, most significant bit first. Because every digit has its own column, a binary clock is read digit by digit rather than as one big binary number.

You can also read the full theory in the lesson on BCD. Prefer to build it yourself from scratch? Open the digiwleea lab and place the gates on the canvas, or start from the logic gate simulator.

Build more parts from gates

half adderfull adderhalf subtractorfull subtractor2:1 multiplexer4:1 multiplexerXOR gate from NAND gates2-to-4 decoderSR latchD flip-flopJK flip-flopT flip-flop4-bit shift register4-bit ripple carry adderD latch1-to-4 demultiplexer4-bit magnitude comparator4-bit ring counter4-bit Johnson counter4-to-2 priority encoder4-bit synchronous counter3-to-8 decoder8-to-1 multiplexer4-bit carry lookahead adderhalf adder from NAND gates2-bit comparatorBCD to 7-segment decoder4-bit up/down counterdecade counter2-bit multiplier4-bit ALU4-bit array multiplierNOT, AND, OR and NOR from NANDNOT, OR, AND and XOR from NORfull adder from NAND gatesSR latch from NAND gatesparity generator and checker4-bit adder/subtractorBCD adder4-bit universal shift registermod-6 counter4-bit ripple counterbinary to Gray code converterhalf adder from NOR gatesfull adder from NOR gates4-bit register with parallel load1011 sequence detectorbinary to BCD converterD flip-flop from NAND gates1-bit ALUCMOS inverterCMOS NAND gateCMOS NOR gatePISO shift registerSR flip-flop from NAND gatesBCD to excess-3 code converterHamming (7,4) code encoder and correctortraffic light controller4-bit barrel shifterCMOS AND gateCMOS OR gateCMOS XOR gate1-bit magnitude comparatorhalf subtractor from NAND gatesfull subtractor from NAND gates8-to-3 encoderGray to binary converter4-to-16 decoderfull adder using 4:1 multiplexersedge detectorserial adder4-bit carry-select adder4-bit Kogge-Stone adder4-bit carry-skip adder4x4 Wallace tree multiplier8-bit adderfrequency divider (by 2, 4 and 3)switch debouncer (SR latch)3-bit Gray code counterMealy machine (1011 detector)master-slave JK flip-flop (NAND)half subtractor from NOR gates1-to-8 demultiplexerexcess-3 to BCD code convertervending machine FSM4-bit carry-save adder3-bit synchronous counter (JK)CMOS transmission gatetri-state buffer (CMOS)2-to-1 mux from transmission gatesmod-5 counterflip-flop conversion (JK to D)8-bit ALUdecimal to BCD encoderBCD to decimal decoder4-to-1 mux from 2-to-1 muxesXOR gate from NOR gates4-bit LFSR74LS138 decoderBCD subtractor74181 ALUCMOS AOI gate (AOI21)D latch vs D flip-flop74LS47 BCD to 7-segment decoder74HC595 shift register7400 quad NAND gate chip7402 quad NOR gate chip7404 hex inverter chip7408 quad AND gate chip7432 quad OR gate chip7486 quad XOR gate chip7474 dual D flip-flop74HC165 shift registerCD4017 decade counter74LS283 4-bit adder74LS90 decade counter74HC161 4-bit counter74HC151 8-to-1 multiplexer74HC157 quad 2-to-1 multiplexer74HC139 dual 2-to-4 decoderCD4511 BCD to 7-segment decoder7492 divide-by-12 counter7493 4-bit binary counter74HC244 octal bufferRace-around condition (JK latch)74HC373 octal latch74HC374 octal D flip-flopTurnstile state machine1-to-2 demultiplexerhalf adder using 2:1 multiplexersregister file (4 x 4-bit)digital PWM generatorCD4013 dual D flip-flop74LS76 dual JK flip-flop7410 triple 3-input NAND chip7411 triple 3-input AND chip7420 dual 4-input NAND chipCD4011 quad 2-input NAND chipCD4001 quad 2-input NOR chipCD4081 quad 2-input AND chipCD4069 hex inverter chip74HC164 8-bit shift register7485 4-bit magnitude comparator74HC125 quad tri-state bufferCD4040 12-stage binary counterCD4060 14-stage counter and oscillator74LS193 4-bit up/down counterelectronic dice circuitmemory address register (MAR) and MDRhardware stack with a stack pointerdirect-mapped cache8-bit Brent-Kung adder4x4 Dadda multiplier

Each of these is one step from a transistor to a working CPU. Build every gate from CMOS transistors and work all the way up in the free digiwleea lab, with the free theory reference alongside.

Open the binary clock circuit in the lab →

Frequently asked

How do you read a binary clock?

Each column is one digit of the time in binary-coded decimal. Add the values of the lit bits in a column (8, 4, 2, 1 from the top) to get that digit, then read the digits left to right as HH:MM, or HH:MM:SS if the clock shows seconds.

How does a binary clock work inside?

A chain of BCD counters, one per digit, all on one clock. Each digit counts up when every digit to its right is at its maximum (9, or 5 for the tens of minutes and seconds), and the hours wrap from 23 to 00 together.

Why does a binary clock use BCD instead of plain binary?

So each decimal digit can be read on its own. In plain binary the minutes 0 to 59 would need one 6-bit number, which is harder to read at a glance.

How many LEDs does a binary clock need?

For HH:MM in BCD, 13: 2 for the hours tens, 4 for the hours ones, 3 for the minutes tens and 4 for the minutes ones. Showing seconds adds 7 more.