Using the TM1637 LED Tube display

Using this nice 4-digit display with your Arduino

Although the more-graphical displays are terrific (and some are cheap to buy too) , sometimes your application doesn’t need the added coding complexity. And for some projects, a “traditional” 7-segment display is simply a better choice for the project at hand – for example, clocks, GPS speedometers, temperature displays, DMMs, counters… the list is long!

The TM1637 LED tube display is an easy-to-use numeric display type. BTW, TM1637 is the name of the controller chip used in the display module.

The most common is the 0.36″ 4-digit 7-segment red “tube” display, and these are low cost (usually around £1 from China). The 0.36″ refers to the height of the actual display digits (about 9.14mm high).

As I mentioned earlier, these displays are very simply to use – especially in their programming needs. They are driven using a simple 2 wire digital interface – not I2C. You will need a TM1637 library – there are a number available if you Google it. I used one from GitHub.

Our examples below worked with our hardware and with the library we used. Your hardware and libraries may differ.

Because it uses 2-wire serial communcations using standard digital pins, you may independently drive more then one display. 

Just a little side note

There are a number of elements to all Arduino projects – the circuit, coding Sketch, but also the enclosure. I am sorry to say this – but many Arduino projects don’t look very good (physically). I know that most Arduino projects are DIY/hobby devices, but still – you put a lot of effort into the project – to then mount the whole shebang in a standard project box with a roughly made cut-outs. I also know that making decent-looking panels is not easy. However, in this regard, we can probably help you just a bit by offering a nice looking bezel, that hides the rough cut-out you made for the display. See below for more information.

First steps, getting the display wired up

There are 4 connections on the display:

  • VCC – the power (positive) for the display
  • GND – the power (negative) for the display
  • CLK –  a digital signal used the send the data into the display
  • DIO –  the actual display data

Connect the CLK and DIO to digital pins on the Arduino, and define those in your Sketch. In our case, we used D3 for CLK, and D4 for DIO.

A simple counter demo

This is a simple sketch that simply increments all 4 digits in a continuous loop.

//Set up the display
#include 
#define clockPin  3  //change to suit
#define dataPin  4   //change to suit
TM1637Display leddisplay(clockPin, dataPin);

void setup() {

//Set the LED tube brightness
//set value from 0 (dim) to 3 (bright) - these values work with our display
//true and false turns the display ON and OFF
leddisplay.setBrightness(2, true);

} //end setup

//----------------------------

void loop(){

//Count up all four digits, in a loop
for (int x=0;x<10000;x=x+1111){
//the true/false defines whether to display leading zeros
//the 4 tells the display to diaplay 4 digits
//the 0 tells the display to start the 4 digis at the left
leddisplay.showNumberDec(x,true,4,0);
delay(100);}

} //end loop

A Displaying a decimal point

Our display has decimal points (other have a colon in the middle for use as a clock). This Sketch displays the number “12.34”.

//Set up the display
#include 
#define clockPin  3  //change to suit
#define dataPin  4   //change to suit
TM1637Display leddisplay(clockPin, dataPin);
void setup() {

//Set the LED tube brightness
//set value from 0 (dim) to 3 (bright) - these values work with our display
//true and false turns the display ON and OFF
leddisplay.setBrightness(2, true);

//this function display a number, and the binary data defined the position of the decimal point
leddisplay.showNumberDecEx(1234,0b01000000,true,4,0);

} //end setup

//----------------------------

void loop(){

} //end loop

Displaying non-numeric data

Displaying characters or symbols with any 7-segment display has major limitations. However, the TM1637 allows us to control each element of each digit. In this example, we are displaying 23°C.

//Set up the display
#include 
#define clockPin  3  //change to suit
#define dataPin  4   //change to suit
TM1637Display leddisplay(clockPin, dataPin);
//this is the 'degree C' display data
byte data[] = {0b01100011,0b00111001};

void setup() {

//Set the LED tube brightness
//set value from 0 (dim) to 3 (bright) - these values work with our display
//true and false turns the display ON and OFF
leddisplay.setBrightness(2, true);

//display 'degree C'
//this sends 2 data bytes to the screen from position 2 (i.e. from the third digit)
leddisplay.setSegments(data, 2,2);

//this displays the number 23
//it sends 2 digits from position 0 (left most digit)
leddisplay.showNumberDec(23,true,2,0);

} //end setup

//----------------------------

void loop(){

} //end loop

A nice finishing touch

As I mentioned earlier, many Arduino projects can sometime look a bit “DIY”. This is especially the case where you have to try cutting a neat rectangular hole in the project box to accommodate the display. Usually, it never looks great.

We can help you with this important visual aspect. We make bezels to suit various Arduino displays, and we make them from glossy acrylic.

See the difference a bezel makes, in these two photos. The display attaches into the rear of the bezel and the bezel is glued into your front panel. Apart from getting rid of ugly screws holding the display to the front panel, overall it looks neater and more professional! You can see full details here, or buy one from our eBay shop.