TM1637 7-segment driver Arduino Example

TM1637 is a 7 segment display driver with great functionalities. In this small tutorial I will show you how to display custom messages with the use of segments and display numbers using the TM1637 library by Avishay Orpaz

To use the driver Library you have to install it inside the Arduino IDE. Search for the TM1637 package by Avishay Orpaz

https://github.com/avishorp/TM1637

The wirring diagram

Wirring diagram for 4 digit 7 segment display

To control each segment with the library to make custom messages the following segment-letter guide will be helpful

7 Segment Display Segment diagram
#include <TM1637Display.h>

#define CLK_pin 2
#define DIO_pin 3

const uint8_t SEG_MSG1[] = {
	SEG_A | SEG_F | SEG_G | SEG_C | SEG_D,          // S
	SEG_A | SEG_F | SEG_E,				// T
	SEG_A | SEG_F | SEG_B | SEG_G | SEG_E | SEG_C,	// A
	SEG_F | SEG_B |SEG_G | SEG_C			// Y
};

const uint8_t SEG_MSG2[] = {
	SEG_A | SEG_F | SEG_G | SEG_C | SEG_D,          // S
	SEG_A | SEG_F | SEG_B | SEG_G | SEG_E | SEG_C,  // A
	SEG_A | SEG_F | SEG_G | SEG_E,                  // F
	SEG_A | SEG_F | SEG_F | SEG_G | SEG_E | SEG_D   // E :)
};

TM1637Display display(CLK_pin, DIO_pin);

// The setup() function runs once each time the micro-controller starts
void setup()
{
	display.setBrightness(0x0f); //important to see something :)
	display.setSegments(SEG_MSG1);
	delay(1000);
	display.setSegments(SEG_MSG2);
	delay(1000);
}

// Add the main program code into the continuous loop() function
void loop()
{
	
	display.clear();

	for (int i = 0; i <= 9999; i++) {
		display.showNumberDec(i);
		delay(500);
	}

}

Leave a Reply

Your email address will not be published. Required fields are marked *