Post Page Advertisement [Top]

tutorial

Interfacing TM1637 Using Arduino


Data collected with a sensor connected to an Arduino can be presented in many ways. The most simple is via Serial Monitor. There are visually more exciting ways, for instance through LCD-, OLED-, TFT- or other displays. Here we focus on digital technology: the 7-segment led display. The advantage of a numerical digital display is that there is immediate visual output. The type discussed here is based on the TM1637 integrated circuit manufactured by Titan Micro Electronics.

Description:

TM1637 is a chip for driving 7-segment displays. There are several modules using this chip to form a 4 digit numerical display module (sometimes called "Digital Tube").

Key Features:
    1. Use either raw segment values or decimal numbers (with and without leading zero).
    2. Set either the whole display or any digit independently.
    3. Control the brightness.
    4. Pure software implementation.
7-segment led display technology:

Basics of 7-segment display technology.
 One ‘digit’ of the display consists of a mask that creates the segments. Any number between 0 and 9 can be created by lighting up a combination of segments. Each segment has its own led.

A 7-segment display is just a mask with 7 LEDs behind it. These LEDs are identified with letters: ‘a’ through ‘ g’. It is amazing that seven LEDs lighting up in various combinations can be used to display any number between 0 and 9 (or, in hexadecimal, between 0 and F). The on-off state of seven LEDs can be controlled with one byte of information. That, and the robustness and the modest energy consumption of individual LEDs makes the 7-segment display interesting for application as a display in an Arduino microcontroller environment. Even some letters can be generated, for instance, the letter ‘F’ can be generated by illuminating bars ‘a’,’f’, ’g’ and ‘e’.

Link to download library:

Connections:
     1. VCC - 5v
     2. GND - GND
     3. CLK - Clock; (Input pin), connect to any digital pin on the Arduino
     4. DIO - Data I/O; (Input pin), connect to any digital pin on the Arduino


Code:

#include <TM1637Display.h>

const int CLK = 9;         //Set the CLK pin connection to the display
const int DIO = 8;          //Set the DIO pin connection to the display


int NumStep = 0;  //Variable to interate

TM1637Display display(CLK, DIO);  //set up the 4-Digit Display.

void setup()
{
  display.setBrightness(0x0a);  //set the diplay to maximum brightness
}


void loop()
{
  for(NumStep = 0; NumStep < 9999; NumStep++)  //Interrate NumStep
  {
    display.showNumberDec(NumStep);     //Display the Variable value;
    delay(500);                                    //A half second delay between steps.
  }
}

Output:

You will get numbers displayed on the 7 segments starting from “0” to “9999”

Note:

  • setSegments - Set the raw value of the segments of each digit
  • showNumberDec - Display a decimal number
  • showNumberDecEx - Display a decimal number with decimal points or colon
  • setBrightness - Sets the brightness of the display

No comments:

Post a Comment

Bottom Ad [Post Page]