LED indicator TM1637 and Arduino – wiring diagram

Often projects require us to output data from various sensors and devices to a port monitor or to a display, for example, to output data from a temperature sensor. Many of you are already familiar with the budget LCD display 1602, connected via an i2c interface.
tm1637-and-arduino-2

Often projects require us to output data from various sensors and devices to a port monitor or to a display, for example, to output data from a temperature sensor. Many of you are already familiar with the budget LCD display 1602, connected via an i2c interface.

But there are also LED displays. They can be used to output the same data, but in a more convenient format: due to the larger display size, data is easier to read, and with their help, you can create a project like a real clock!

In this article, we will disassemble the device LED indicator TM1637, learn how to connect it to the Arduino and write the program code to work with it!

To implement the project from this article, we need the following components:

  • Arduino Uno R3
  • Seven-segment indicator TM1637
  • Breadboard
  • Wires

MODULE OVERVIEW


LED indicator TM1637 and Arduino – wiring diagram
The module is a small board on which a 4-digit seven-segment LED display is installed based on the TM1637 i2c driver of the same name.

Externally, the design is quite simple, and we will not dwell on this much. Unless, it can be noted that sometimes a module is sold as an 8-bit version, which will occupy more leads for connecting to the Arduino.

Also on some displays, there is a clock separator, in the form of a colon. That is why the TM1637 indicator found very wide use in DIY watches on the Arduino.

CONNECTION SCHEME


Due to the presence of the i2c interface onboard, the module is connected very simply – using four pins. Two of them are responsible for the power supply and are connected to the 5V and Gnd terminals on the Power panel of our controller; the other two, called CLK and DIO, will connect to digital outputs, for example, 3 and 2, respectively.

A visual wiring diagram, for your convenience, is shown in the picture on the right:

CONNECTING TO ARDUINO IDE
Before you start writing the program code, and then puzzling over more complex projects, you need to download a specialized library for our display – tm1637.h.
Simultaneously with the loaded library, three new codes will appear in the “examples” folder for review and performance checks. Let’s get acquainted with one of them.
The code below displays any 4 characters that we pre-compile, and also turns the clock separator on and off with a delay of 1 second (1000 milliseconds):

#include “TM1637.h” 
int8_t DispMSG[] = {1, 2, 3, 4}; 
#define CLK 3
#define DIO 2
TM1637 tm1637(CLK, DIO);
void setup()
{
tm1637.init();
/*
BRIGHT_TYPICAL = 2
BRIGHT_DARKEST = 0
BRIGHTEST = 7
*/
tm1637.set(BRIGHT_TYPICAL);
}
void loop()
{
tm1637.point(true);
tm1637.display(DispMSG);
delay(1000);
tm1637.point(false);
tm1637.display(DispMSG);
delay(1000);
}

After loading and successful compilation of this code, we will see the numbers 1, 2, 3, 4 on the LED screen.

DISPLAY DATA OUTPUT
If we want to display data on the display, for example from a temperature sensor, the following code will help us with this:

#include “dht.h”
#include “TM1637.h”
#define dht_pin 2 
#define CLK 3
#define DIO 2
TM1637 tm1637(CLK, DIO);
dht DHT;
void setup() {
tm1637.init();
tm1637.set(BRIGHT_TYPICAL);
delay(1500);
}
void loop() {
DHT.read11(dht_pin);
int temp = DHT.temperature;
int humidity = DHT.humidity;
int digitoneT = temp / 10;
int digittwoT = temp % 10;
int digitoneH = humidity / 10;
int digittwoH = humidity % 10;
tm1637.display(1, digitoneT);
tm1637.display(2, digittwoT);
tm1637.display(3, 12);
delay (5000);
tm1637.display(1, digitoneH);
tm1637.display(2, digittwoH);
tm1637.display(3, 15);
delay(5000);
}

Please note that we also first connect a separate library for the temperature and humidity sensor DHT. Numbers and letters are also written for our display, but they do not refer to the code — this part of the code only shows us that the library allows the module to display numbers from 0 to 9 in the usual mode, and from 10 to 15 in the form of letters.

Next, we prescribe what output we connect our modules to, compared to the previous scheme, we add a digital output connection from the temperature sensor to pin number 2.

In the void setup function, we initialize the sensors and start the cycle. In the cycle itself, we read the readings from the temperature sensor: in the variable temp we save the temperature value and in the humidity value humidity.

Next, these values are divided by 10 in order to display these data on our display, since information on a seven-segment display can be displayed only character-by-character.

The last eight lines are devoted to displaying data directly on the display. The last value is the symbol C, for temperature and F for humidity. And also put a delay of 5 seconds between the transfer of evidence.

On this, our article came to an end. We hope that the material was useful for you and you can apply the knowledge and experience gained in your own cool projects! All successful compilation, follow our blog!

Share on facebook
Facebook
Share on google
Google+
Share on twitter
Twitter
Share on linkedin
LinkedIn
Share on pinterest
Pinterest