TM1637 Digit Display - Arduino Quick Tutorial

TM1637 Digit Display - Arduino Quick Tutorial © GPL3+

Learn how to quickly use the TM1637 Digit Display!

  • 25,400 views
  • 5 comments
  • 9 respects

Components and supplies

Ph a000066 iso (1) ztbmubhmho
Arduino UNO
Any Arduino should work
×1
TM1637 Digit Display
×1
11026 02
Jumper wires (generic)
×1

Apps and online services

About this project

About

The TM-1637 (also called the Grove 4-Digit Display by Seeed Studio) is a 7-segment 4-digit display that can be easily controlled with a few wires on an Arduino.

Instructions

1.) Build the circuit according to the circuit diagram.

2.) Install the TM1637 library in the Arduino IDE by going to Sketch>Include Library>Manage Libraries. Then, type in "TM1637" and install the library labeled "Grove 4-Digit Display" by Seeed Studio.

3.) Type in the setup code (This can be found in the "Code" section of this page):

#include <TM1637.h>

int CLK = 2;
int DIO = 3;

TM1637 tm(CLK,DIO);

void setup() {
// put your setup code here, to run once:
tm.init();

// set brightness; 0-7
tm.set(2);
}

CLK and DIO can be set to any pin on the Arduino, they do not have to be pins 2 and 3.

To set the brightness, pass in a value between 0-7 into tm.set();

4.) Now you can display characters in the loop function with 2 methods:

a.) tm.display(<position>, <character> ); will display a character on the display.

Position refers to the digit you want to change. The first is 0 and the last is 3.

Character refers to the character you want to display. 0-9 displays 0-9 and 10-15 displays A-F

Here is an example that displays "12:Ab":

void loop() {
// put your main code here, to run repeatedly:

// example: "12:ab"
// tm.display(position, character);
tm.display(0,1);
tm.display(1,2);
tm.point(1);
tm.display(2,10);
tm.display(3,11);
}

5.) Connect your Arduino to the computer and upload the sketch.

A Few Useful Functions

Easily Display a number: To make displaying numbers easier, here is a function that will display integers that you pass into it:

void displayNumber(int num){   
tm.display(3, num % 10);
tm.display(2, num / 10 % 10);
tm.display(1, num / 100 % 10);
tm.display(0, num / 1000 % 10);
}

To make it display "1234" for example, you can just call displayNumber(1234);


Easily Display a Time: To make it display a time in the form minutes:seconds based on the number of seconds, you can use this function:

void displayTime(int seconds){
int minutes = seconds / 60;
int seconds = seconds % 60;

tm.point(1);
tm.display(3, seconds % 10);
tm.display(2, seconds / 10 % 10);
tm.display(1, minutes % 10);
tm.display(0, minutes / 10 % 10);
}

To make it display "15:30" for example, you can just call displayTime(930); (There are 930 seconds in 15 minutes 30 seconds).

Video Tutorial

Video Tutorial


Code

Example CodeC/C++
#include <TM1637.h>

int CLK = 2;
int DIO = 3;

TM1637 tm(CLK,DIO);

void setup() {
  // put your setup code here, to run once:
  tm.init();

  //set brightness; 0-7
  tm.set(2);
}

void loop() {
  // put your main code here, to run repeatedly:

  // example: "12:ab"
  // tm.display(position, character);
  tm.display(0,1);
  tm.display(1,2);
  tm.point(1);
  tm.display(2,10);
  tm.display(3,11);

  delay(1000);

  // example: "1234"
  displayNumber(1234);

  delay(1000);
}

void displayNumber(int num){   
    tm.display(3, num % 10);   
    tm.display(2, num / 10 % 10);   
    tm.display(1, num / 100 % 10);   
    tm.display(0, num / 1000 % 10);
}

Schematics

Diagram
Tm1637 sketch bb cxdapye3vh

Comments

Similar projects you might like

GPS Location Display With GPS And TFT Display Shields

Project tutorial by Boian Mitov

  • 27,056 views
  • 8 comments
  • 41 respects

Four Digit Seven Segment Display Tutorial Enhancement

Project tutorial by TheLostGhost

  • 2,412 views
  • 0 comments
  • 6 respects

Control a 7 Segment Display with a keypad!

Project tutorial by Isaac100

  • 33,993 views
  • 21 comments
  • 39 respects

8bit Number Display

Project tutorial by Alireza Karkon

  • 2,540 views
  • 0 comments
  • 7 respects
Add projectSign up / Login