Friday 4 November 2016

TM1637 4-digit 7-segment display

There are many different display modules that use a TM1637 IC from Titan MicroElectronics.
The color, size, dots, and connection points can vary widely, but as long as they use the TM1637,
 most should work.
 

A naked  4-digit 7-segment display will use 12 pins on your arduino.
The TM1637 cuts this down to 4.
 

The 4 connections are 
VCC 5V/3.3V
GND
CLK (clock)
DIO (Data I/O)

CLK & DIO are connected to any arduino digital pins.
It's your choice.
 
Each display is actually a collection of 7 LEDs
The individual segments are labelled A to G
By setting each LED to high or low, we can turn them on/off
 
The TM1637 module includes four 0.36 segment 7-segment displays.
 
You’ll need to use a library or two.
 
Which one depends on the type of module you have.
Avishay Orpaz has written a great library for TM1637 displays, the TM1637Display library.  
 These require this compiler directive to be placed in your code:
// Include the library
#include <TM1637Display.h>

I have another TM display that uses the Grove library

You need to put this into your code:

// include the grove.seeedstudio library 
#include <TM1637.h> 
 And then define the pins
 
// Define the connections pins
#define CLK 2
#define DIO 3
 
Next, we need the function  
TM1637Display()
or
 TM1637 tm(2, 3);

This function requires two parameters:
the CLK pin and the the DIO pin.
TM1637Display display = TM1637Display(CLK, DIO);
OR 
 TM1637 tm(2, 3);
The code depends on the type of display you have.
Before you buy it, research what library it needs. 

The main functions include:

  • 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() – Set the brightness of the display
  • clear() – Clear the display
 Here is a simple display sketch.
It's actually the basic example in the ARDUINO IDE. 
 
These TM1637 Driver examples work well.
They all use the 
#include <TM1637.h> 
//************************** 
 code 1
This refers to displays that use the  #include <TM1637.h> library
To set the brightness, pass in a value between 0-7 into tm.setBrightness(); 
tm.display(); will display a character on the display. 
You are restricted to just 4 characters. 
Simply type in any alpha-numeric characters you wish. 
 

//*******************
#include <TM1637.h>


// Instantiation and pins configurations
// Pin 3 - > DIO
// Pin 2 - > CLK
TM1637 tm(2, 3);

void setup()
{
    tm.begin();
    tm.setBrightness(4);
}

void loop()
{
    // Display Integers:
    tm.display(1234);
    delay(1000);

    // Display float:
    tm.display(29.65);
    delay(1000);

    // Display String:
    tm.display("PLAY");
    delay(1000);
    tm.display("STOP");
    delay(1000);
}
//*******************************************************
  
Links
+ https://www.makerguides.com/tm1637-arduino-tutorial/
+ https://www.instructables.com/Tutorial-How-to-4-Digit-Display-Interface-With-Ard/ 
+ https://www.youtube.com/watch?v=6W7tycX-F1o&t=64s 
+ https://www.youtube.com/watch?v=l6QoGsdHzfM
 
 ---------------------------------
-------------------------------------

No comments:

Post a Comment