The TM1638 is an integrated circuit designed by TM that combines an LED display driver and a key scan interface. This versatile component is widely used in microcontroller projects to control 7-segment displays and read input from a matrix of switches. Its ability to handle both display and input functions makes it an excellent choice for creating user interfaces in embedded systems.
Parameter | Value |
---|---|
Operating Voltage | 5V |
Operating Current | 80mA (typical) |
Display Type | 8-digit 7-segment LED |
Key Scan | 8x3 matrix |
Communication | Serial (3-wire interface) |
Package Type | SOP-28 |
Pin No. | Pin Name | Description |
---|---|---|
1 | VDD | Power Supply (5V) |
2 | GND | Ground |
3 | DIO | Data Input/Output |
4 | CLK | Clock Input |
5 | STB | Strobe (Chip Select) |
6-13 | SEG1-SEG8 | Segment Outputs for 7-segment displays |
14-21 | GRID1-GRID8 | Grid Outputs for 7-segment displays |
22-28 | K1-K8 | Key Scan Inputs |
#include <TM1638.h>
// Define the pins for the TM1638 module
#define DIO_PIN 2
#define CLK_PIN 3
#define STB_PIN 4
// Create an instance of the TM1638 class
TM1638 module(DIO_PIN, CLK_PIN, STB_PIN);
void setup() {
// Initialize the module
module.setupDisplay(true, 7); // Turn on display, set brightness to max (7)
}
void loop() {
// Display a number on the 7-segment display
module.setDisplayToDecNumber(12345678, 0x00, true);
// Read the key inputs
uint8_t keys = module.getButtons();
// Check if any key is pressed
if (keys != 0) {
// Display the key value on the first digit
module.setDisplayDigit(keys, 0, false);
}
delay(100); // Small delay to debounce keys
}
The TM1638 display and switch module is a powerful and versatile component for creating interactive displays and user interfaces in microcontroller projects. By following the guidelines and best practices outlined in this documentation, users can effectively integrate the TM1638 into their projects and troubleshoot common issues with ease.