You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Arduino Library for the TM1637 Based LED Display Module
6
7
7
8
## Description
9
+
8
10
This is an Arduino library for 4 and 6 digit 7-segment LED display modules based on the TM1637 chip.
9
11
Connect the TM1637 display CLK and DIO pins to your Arduino GPIO pins, include this library, initialize TM1637TinyDisplay and call easy to use functions like showNumber(), showString(), showLevel() and showAnimation(). Display will scroll text for larger strings. Functions support screen splitting for easy number + text formatting. Library also runs well on tiny controllers including the ATtiny85.
10
12
11
-
## Hardware
13
+
## Hardware
14
+
12
15

13
16
14
17
* 4-Digit Display modules based on the TM1637 chip are available from [HiLetgo](https://www.amazon.com/gp/product/B01DKISMXK/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1), [DX](https://dx.com/p/0-36-led-4-digit-display-module-for-arduino-black-blue-works-with-official-arduino-boards-254978) and [SeeedStudio](https://www.digikey.com/products/en?keywords=tm1637).
@@ -17,8 +20,9 @@ Connect the TM1637 display CLK and DIO pins to your Arduino GPIO pins, include t
17
20

18
21
19
22
The display has four connectors:
20
-
* CLK - Clock - attach to any GPIO output
21
-
* DIO - Data - attach to any GPIO output
23
+
24
+
* CLK - Clock - attach to any GPIO output
25
+
* DIO - Data - attach to any GPIO output
22
26
* VCC - Power 5v
23
27
* GND - Ground
24
28
@@ -27,39 +31,13 @@ Power Note: Steady clean power is important for circuit stability. If you are se
27
31
Decimals and Colons: Some TM1637 displays come equipped with a middle colon LED (as shown above) as used in digital clocks but with no decimal points. Some displays come with decimal point LEDS for each digit. Some come with both but often the decimal point LEDs are not connected. These extra LEDs are activated by setting the upper bit (0x80) for the digit next to the dot. This library will handle setting that for you via the showNumber() function when you specify floating point numbers or via the showNumberDec() function where you can set the decimal point manually.
28
32
29
33
## Installation
34
+
30
35
This library is available via the Arduino IDE. Install this library via `Tools`, `Manage Libraries`, search for "TM1637TinyDisplay" and click `Install`.
31
36
32
37
Alternatively, you can install this manually by cloning this repo into your Arduino library folder (e.g. `~/Documents/Arduino/libraries`).
33
38
34
-
## Usage
35
-
The library provides a single class named TM1637TinyDisplay with the following functions:
36
-
37
-
*`showNumber` - Display an integer and floating point numbers (positive or negative)
38
-
*`showNumberDec` - Display a number with ability to manually set decimal points or colon
39
-
*`showNumberHex` - Display a number in hexadecimal format and set decimal point or colon
40
-
*`showString` - Display a ASCII string of text with optional scrolling for long strings
41
-
*`showLevel` - Use display LEDs to simulate a level indicator (vertical or horizontal)
42
-
*`showAnimation` - Display a sequence of frames to render an animation
43
-
*`startAnimation` - Begins a non-blocking animation of a sequence of frames
44
-
*`startStringScroll` - Begins a non-blocking scrolling of a string message
45
-
*`Animate` - Worker routine to be called regularly which handles animations and scrolling in a non-blocking manner
46
-
*`setSegments` - Directly set the value of the LED segments in each digit
47
-
*`setBrightness` - Sets the brightness of the display
48
-
*`setScrolldelay` - Sets the speed for text scrolling
49
-
*`flipDisplay` - Sets/flips the orientation of the display
50
-
*`isflipDisplay` - Returns orientation of the display (True = flip)
51
-
*`readBuffer` - Returns current display segment values
52
-
53
-
PROGMEM functions: Large string or animation data can be left in Flash instead of being loaded in to SRAM to save memory.
54
-
55
-
*`showAnimation_P` - Display a sequence of frames to render an animation (in PROGMEM)
56
-
*`showString_P` - Display a ASCII string of text with optional scrolling for long strings (in PROGMEM)
57
-
*`startAnimation_P` - Begins a non-blocking animation of a sequence of frames stored in PROGMEM
58
-
*`startStringScroll_P` - Begins a non-blocking scrolling of a string message stored in PROGMEM
59
-
60
-
61
-
62
39
## Example Code
40
+
63
41
```cpp
64
42
#include<Arduino.h>
65
43
#include<TM1637TinyDisplay.h>
@@ -68,11 +46,13 @@ PROGMEM functions: Large string or animation data can be left in Flash instead o
68
46
#defineCLK 1
69
47
#define DIO 2
70
48
71
-
//Initialize TM1637TinyDisplay
49
+
//Instantiate TM1637TinyDisplay Class
72
50
TM1637TinyDisplay display(CLK, DIO);
73
51
74
52
void setup() {
75
-
display.setBrightness(0x0f);
53
+
// Initialize Display
54
+
display.begin();
55
+
display.setBrightness(BRIGHT_HIGH);
76
56
}
77
57
78
58
void loop() {
@@ -111,9 +91,8 @@ void loop() {
111
91
}
112
92
```
113
93
114
-
Refer to [TM1637TinyDisplay.h](TM1637TinyDisplay.h) for information on available functions. See also [Examples](examples) for more demonstration.
115
-
116
94
## Animation and Animator Tool
95
+
117
96
The showAnimation() function projects a sequence of frames (patterns) onto the display. This works by defining the animation sequence through a multi-dimensional array of patterns.
118
97
119
98
You can use the included javascript based interactive [7-Segment LED Animator Tool](https://jasonacox.github.io/TM1637TinyDisplay/examples/7-segment-animator.html) to help build your animation. The source code is in the [Examples](examples) folder. This tool will let you set up the LED sequences you want, save each frame and copy the final code (a static array) directly into your sketch to use for the `showAnimation(data, frames, timing)` function. Here is an example:
0 commit comments