{"id":13894119,"url":"https://github.com/Erriez/ErriezTM1638","last_synced_at":"2025-07-17T08:32:24.074Z","repository":{"id":85067623,"uuid":"118962878","full_name":"Erriez/ErriezTM1638","owner":"Erriez","description":"TM1638 LED driver with key-scan library for Arduino","archived":false,"fork":false,"pushed_at":"2020-08-28T17:55:33.000Z","size":6105,"stargazers_count":14,"open_issues_count":0,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-19T04:44:04.878Z","etag":null,"topics":["arduino","c-plus-plus","documentation","esp32","esp8266","examples","getting","key-scan","led","library","started","tm1638","uno"],"latest_commit_sha":null,"homepage":"https://github.com/Erriez/ErriezArduinoLibrariesAndSketches","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Erriez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-25T20:16:04.000Z","updated_at":"2024-10-18T22:38:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"f73343be-4d5a-4d02-ba6e-61f1bf9a0b6e","html_url":"https://github.com/Erriez/ErriezTM1638","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Erriez%2FErriezTM1638","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Erriez%2FErriezTM1638/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Erriez%2FErriezTM1638/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Erriez%2FErriezTM1638/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Erriez","download_url":"https://codeload.github.com/Erriez/ErriezTM1638/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226243893,"owners_count":17594452,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino","c-plus-plus","documentation","esp32","esp8266","examples","getting","key-scan","led","library","started","tm1638","uno"],"created_at":"2024-08-06T18:01:24.314Z","updated_at":"2024-11-24T22:31:15.855Z","avatar_url":"https://github.com/Erriez.png","language":"C++","funding_links":[],"categories":["C++"],"sub_categories":[],"readme":"# Optimized TM1638 library for Arduino\n[![Build Status](https://travis-ci.org/Erriez/ErriezTM1638.svg?branch=master)](https://travis-ci.org/Erriez/ErriezTM1638)\n\nThis is a 3-pin serial TM1638 chip library for Arduino, optimized for size and speed. It supports a combined LED driver controller and key-scan interface to detect multiple key presses at the same time.\n\n![TM1638 chip](https://raw.githubusercontent.com/Erriez/ErriezTM1638/master/extras/TM1638_pins.jpg)\n\nDisplaying numbers, characters and reading keys depends on the hardware wiring and is not part of this library. A fully operational example for a board with 8 7-segment displays, 8 dual color LED's and 8 buttons which uses this library is available here: [JY-LKM1638](https://github.com/Erriez/ErriezLKM1638).\n\n\n## Hardware\n\nConnect power and 3 data pins to an Arduino board DIGITAL pins:\n* VDD (Power 3.3V - 5V)\n* GND (Ground)\n* DIO (Bi-directional data input/output)\n* STB (Chip select)\n* CLK (Clock)\n\nThe following TM1638 pins should be connected to LED's and buttons in a matrix:  \n* K1~K3 (Key-scan data input to read multiple key presses at the same time)\n* SEG/GRID (Output for LED matrix)\n\n\n## Pins\n\n| Pin  | TM1638 | Arduino UNO / Nano / Micro / Pro Micro / Leonardo / Mega2560 | WeMos D1 \u0026 R2 / Node MCU | WeMos LOLIN32 |\n| :--: | :----: | :----------------------------------------------------------: | :----------------------: | :-----------: |\n|  1   |  VCC   |                         5V (or 3.3V)                         |           3V3            |      3V3      |\n|  2   |  GND   |                             GND                              |           GND            |      GND      |\n|  3   |  CLK   |                       2 (DIGITAL pin)                        |            D2            |       0       |\n|  4   |  DIO   |                       3 (DIGITAL pin)                        |            D3            |       4       |\n|  5   |  STB0  |                       4 (DIGITAL pin)                        |            D4            |       5       |\n\n* Check maximum regulator / diode current to prevent a burnout when using lots of LED's. Some boards can provide only 100mA, others 800mA max.\n\n\n## Example\n\nArduino IDE | Examples | Erriez TM1638 button and LED driver:\n\n* [ErriezTM1638](https://github.com/Erriez/ErriezTM1638/blob/master/examples/ErriezTM1638/ErriezTM1638.ino)\n\n\n## Documentation\n\n- [Doxygen online HTML](https://Erriez.github.io/ErriezTM1638)\n- [Doxygen PDF](https://github.com/Erriez/ErriezTM1638/raw/master/ErriezTM1638.pdf)\n- [TM1638 Datasheet](https://github.com/Erriez/ErriezTM1638/blob/master/extras/TM1638_datasheet.pdf)\n\n\n## Usage\n\n**Initialization**\n\n```c++\n// Include TM1638 library\n#include \u003cErriezTM1638.h\u003e\n\n// Connect display pins to the Arduino DIGITAL pins\n#define TM1638_CLK_PIN   2\n#define TM1638_DIO_PIN   3\n#define TM1638_STB_PIN   4\n\n// Create tm1638 object\nTM1638 tm1638(TM1638_CLK_PIN, TM1638_DIO_PIN, TM1638_STB_PIN);\n\nvoid setup()\n{\n    // Initialize TM1638\n    tm1638.begin();\n}\n```\n\n**Display on/off**\n\n```c++\n// Turn display off\ntm1638.displayOff();\n  \n// Turn display on\ntm1638.displayOn();\n```\n\n**Turn all LED's off**\n\n```c++\n// Turn all LED's off\ntm1638.clear();\n```\n\n**Get keys**\n\n```c++\n// Get 32-bit key-scan\nuint32_t keys = tm1638.getKeys();\n```\n\n**Write Byte to display register**\n\n```c++\n// Write segment LED's to the first display registers 0x00..0x0F with value 0x00..0xff to\n// display numbers and characters. Just an example which depends on the hardware:\ntm1638.writeData(0x01, 0x01);\n```\n\n**Write buffer to display registers**\n\n```c++\n// Creat buffer with LED's\nuint8_t buf[] = { 0b10000110, 0b00111111, 0b00111111, 0b00111111, 0b00111111, 0b00111111};\n\n// Write buffer to TM1638\ntm1638.writeData(0x00, buf, sizeof(buf));\n```\n\n## Small footprint\n\nMeasured with Arduino IDE v1.8.5 without any other peripherals, calling all library functions once:\n\n| Board       | MCU flash size | MCU RAM size | TM1638 library flash | TM1638 library RAM |\n| ----------- | :------------: | :----------: | :------------------: | :----------------: |\n| Arduino UNO |      32kB      |    2048kB    |      1840 Bytes      |      40 Bytes      |\n\n## Optimized timing\n\nThe library uses optimized pin control for AVR targets. Other targets uses the default digitalRead() and digitalWrite() pin control functions.\n\nOutput [Benchmark](https://github.com/Erriez/ErriezTM1638/blob/master/examples/Benchmark/Benchmark.ino) example:\n\n| Board                |  CLK   | Read keys | Write Byte | Write 16 Bytes buffer | Clear display |\n| -------------------- | :----: | :-------: | :--------: | :-------------------: | :-----------: |\n| Pro Mini 8MHz        | 65kHz  |   736us   |   312us    |        2448us         |    2224us     |\n| UNO 16MHz            | 125kHz |   340us   |   152us    |        1192us         |    1176us     |\n| WeMos D1 \u0026 R2 80MHz  | 200kHz |   284us   |   116us    |         683us         |     682us     |\n| WeMos D1 \u0026 R2 160MHz | 300kHz |   223us   |    66us    |         474us         |     469us     |\n\n#### Arduino UNO 16MHz\n\n![TM1638 Arduino UNO 16MHz timing](https://raw.githubusercontent.com/Erriez/ErriezTM1638/master/extras/TM1638_timing_Arduino_UNO_16MHz.png)\n\n#### WeMos D1 \u0026 R2 80MHz\n\n![TM1638 WeMos D1 \u0026 R2 40MHz timing](https://raw.githubusercontent.com/Erriez/ErriezTM1638/master/extras/TM1638_timing_WeMos_D1_R2_80MHz.png)\n\n#### WeMos D1 \u0026 R2 160MHz\n\n![TM1638 WeMos D1 \u0026 R2 160MHz timing](https://raw.githubusercontent.com/Erriez/ErriezTM1638/master/extras/TM1638_timing_WeMos_D1_R2_160MHz.png)\n\n## Library dependencies\n\n- The [ErriezTM1638Benchmark](https://github.com/Erriez/ErriezTM1638/blob/master/examples/ErriezTM1638Benchmark/ErriezTM1638Benchmark.ino) example uses [Erriez Timestamp](https://github.com/Erriez/ErriezTimestamp) library.\n\n\n## Library installation\n\nPlease refer to the [Wiki](https://github.com/Erriez/ErriezArduinoLibrariesAndSketches/wiki) page.\n\n\n## Other Arduino Libraries and Sketches from Erriez\n\n* [Erriez Libraries and Sketches](https://github.com/Erriez/ErriezArduinoLibrariesAndSketches)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FErriez%2FErriezTM1638","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FErriez%2FErriezTM1638","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FErriez%2FErriezTM1638/lists"}