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.
Instructions1.) 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 FunctionsEasily 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
Comments