Source: https://mokxi.com/parts/tm1638
Updated: 2026-11-16

Part

# LED and key board, TM1638

Eight digits, eight LEDs and eight buttons on three wires. STB low, bytes least significant bit first.

See every part

- 5 pins
- In 1 project
- In 1 lesson

Drawn live by the editor's own code, at the size you see it.

At a glance

## The LED and key board, TM1638 in brief

What it is, and where it sits on the bench.

The TM1638 LED&KEY board has eight seven-segment digits, eight LEDs and eight buttons on three wires: STB, CLK and DIO, with VCC and GND at 5 V. STB, the strobe, is low for the length of each command. Data is taken on the rising edge of CLK, and DIO carries data both ways: the board drives it to send and the chip pulls it low to answer a key read. The chip holds the picture and scans the buttons itself, so a sketch only sends bytes, which makes it the usual front panel for clocks, counters and scoreboards. The model follows the datasheet’s data, address and display control commands, with sixteen bytes of display RAM. Press the buttons with the pointer.

Family

Displays

Pins

5

Pins

## 5 pins

Named as the editor names them, so a wire lands where you expect it.

Pin

What it does

VCC

Supply, 5 V.

GND

Ground.

STB

Strobe: low for the length of each command.

CLK

The clock; data is taken on its rising edge.

DIO

Data, both ways: the board drives it to send, the chip pulls it low to answer a key read.

How to use it

## How to use a TM1638 LED&KEY board with an Arduino

The board takes three signal wires and 5 V. STB goes to pin 4, CLK to pin 6 and DIO to pin 7, with GND on the Uno’s ground and VCC on 5 V. The sketch uses Gavin Lyons’ TM1638plus library, which Mokxi ships as TM1638plus.h, and its constructor takes the strobe, clock and data pins in that order.

readButtons() returns a byte with one bit for each of the eight buttons, bit 0 being S1. This sketch lights the LED over each held button, counts presses and shows the count and the last button on the eight digits. Click the buttons with the pointer.

Part pin

Board pin

VCC

5 V

GND

GND

STB

Pin 4

CLK

Pin 6

DIO

Pin 7

Click to open it in the editor

This is the simulator itself, running here. Click anything to open it in the editor.

Open this project in the editor Read the full tutorial

Buttons to LEDs

Common errors

## Common LED and key board, TM1638 errors and fixes

What goes wrong

The fix

The digits stay blank.

Call displayBegin() first, then displayText(). Check STB, CLK and DIO are on pins 4, 6 and 7 as in the constructor.

The LEDs light over the wrong buttons.

The LEDs are the odd bytes of the display RAM. setLEDs() takes the button byte shifted left by 8, as above.

No button is seen.

DIO is two way: the chip pulls it low to answer a key read. Do not drive it from the board with a fixed output.

Questions

## Questions and answers

### How many pins does the TM1638 board need?

Three signal pins, STB, CLK and DIO, plus 5 V and ground.

### How many buttons and LEDs does the LED&KEY board have?

Eight of each, with eight seven-segment digits.

### Which library does Mokxi use for the TM1638?

Gavin Lyons’ TM1638plus, as TM1638plus.h.

How it is modeled

## What is true about the LED and key board, TM1638, here

In its help article’s own words: what the simulation gets right, and where it stops.

### Modeled

From the TM1638 datasheet: the data, address and display control commands; bytes
least significant bit first on the rising edge of CLK; auto-increment and fixed
addressing; sixteen bytes of display RAM, the even ones the digits and bit 0 of
the odd ones the LEDs on this board; the eight pulse widths; display off keeping
the RAM. A key read returns four bytes on DIO, open drain against the board's
pull-up, with the board's buttons wired so the usual byte_i << i fold gives one
bit per button.

### Not modeled

The multiplexing (all eight digits are drawn lit at once), the 1 MHz clock limit,
test mode, and the bicolor LEDs of the other TM1638 boards.

From TM1638 LED and key board, in full.

Projects

## See the LED and key board, TM1638 in a project

One built-in project uses it. It opens in the editor, already wired.

Lessons

## Where it turns up in a lesson

One lesson places it in its own circuit.

### Learn articles

1 lesson

- Arduino TM1638: LED&KEY Display, LEDs and Buttons

Boards

## The boards it is shown on

This board has a built-in project with the LED and key board, TM1638 in it.

- Arduino Uno R3

Libraries

## Arduino libraries for the LED and key board, TM1638

Built in, so the sketch compiles with nothing to install. Each page has the calls, the wiring and an example to run.

- TM1638plus

Keep going

## Keep going

- Arduino TM1637 Display: Library and Countdown
- Arduino 4 Digit 7 Segment Display: Wiring and Code
- Four-digit display, TM1637
- Four-digit seven segment, multiplexed
- Eight-digit display, MAX7219

More parts

## The rest of the bench

Every one of these is drawn and simulated the same way.

Full-size breadboard

A real 0.1 inch grid with the rails and the center channel, 63 columns wide.

Jumper wires

Drag from any pin or hole to any other. Corners snap, and you can drag them.

Power

A supply rail at the voltage you choose.

Ground

The other end of every circuit.

LED

Lights when current flows. Five colors, and the brightness is what your eye would see.

Filament lamp

A tungsten bulb in a holder: an inrush when it is switched on cold, tens of milliseconds to warm up, and dim on half its voltage.

Resistor

Any value you like, with the color bands drawn to match.

ESP32-C3-DevKitM-1

A RISC-V board that runs your firmware at 160 MHz on the real memory map.

Pushbutton

A 12 mm tactile switch. Hold it while the simulation runs.

Raspberry Pi Pico

The RP2040 board on our own Cortex-M0+ core. Pick a program and press Run.

Raspberry Pi Pico W

Raspberry Pi Pico W (RP2040). The same board and the same pinout as a Pico, with the CYW43439 on it. The WiFi is simulated (no radio; real internet through the Cloud panel’s switch), and the on-board LED, which hangs off that chip rather than off GP25, is driven through the same path. Everything else is the Pico.

Raspberry Pi 4 Model B

Raspberry Pi 4 Model B: the 40-pin header, driven by main.py with RPi.GPIO or gpiozero.

See every part

## Wire up the LED and key board, TM1638

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.

Start building free Open the editor
