SevenSegmentTM1637: an example that runs
Yes. You can use the SevenSegmentTM1637 library online in Mokxi with nothing to install, and the sketch runs in your browser against the simulated part (Four-digit display, TM1637). The example below, "Text and a time on a TM1637 display", runs on the Arduino Uno R3.
Built in on Mokxi: #include <SevenSegmentTM1637.h> and it builds, with nothing to install. Free, and no account needed.
What SevenSegmentTM1637 does
The four-digit TM1637 display as a Print: print() of text and numbers with scrolling, the colon, backlight in percent, blink, raw segments, and the extended class’s printTime(), printNumber() and printDualCounter(). That is what SevenSegmentTM1637, by Bram Harmsen, covers. The sketch below uses it on the Arduino Uno: “Text and a time on a TM1637 display”.
Bram Harmsen's SevenSegmentTM1637 library (1.1), the four-digit TM1637 display as a Print with the LCD API's calls.
As upstream, println() then writes the line end as two blanks at the cursor. The colon is bit 7 of the second digit, added whenever that digit is written while setColonOn(true). setBacklight() maps 0 to 100 onto off and the chip's eight brightness steps.
The calls follow release 1.1.1 of the library, so a sketch written here builds on a real board too. The example is the one Mokxi's own tests build and run, so what is printed here is what runs.
| Library Manager name | SevenSegmentTM1637 |
|---|---|
| Author | Bram Harmsen |
| Include | #include <SevenSegmentTM1637.h>#include <SevenSegmentExtended.h> |
| Boards | every board Mokxi compiles for |
| In the simulator | Simulated: it runs against the part the way it does on the bench. |
| Parts it drives | Four-digit display, TM1637 |
Install it
It builds on every board Mokxi compiles for.
In Mokxi it is built in: #include <SevenSegmentTM1637.h> and the sketch compiles, with no download, no zip and no Library Manager.
On a real board, install "SevenSegmentTM1637" by Bram Harmsen from the Arduino IDE’s Library Manager (Sketch, Include Library, Manage Libraries), or add SevenSegmentTM1637 to lib_deps in PlatformIO. Mokxi follows the calls of release 1.1.1, so a sketch written here builds there too.
What to know in the simulator: SevenSegmentFun.h (the bouncing ball and other animations) is not here. The font is Mokxi’s own seven-segment alphabet.
- ESP32-C3
- Arduino Uno
- Arduino Nano
- Arduino Mega 2560
- Arduino Leonardo
- SparkFun Pro Micro
- Arduino Micro
- ESP32-C6
- WCH CH32V003
- ATtiny85
- Raspberry Pi Pico
- Raspberry Pi Pico W
- Seeed XIAO SAMD21
- STM32
- STM32 Nucleo-F411RE
- STM32 Blue Pill
- micro:bit V2
- Arduino Uno R4
- ESP32 DevKit
- ESP32-S3-DevKitC-1
- ESP8266 NodeMCU
- Arduino Pro Mini 3.3 V
- Seeed XIAO ESP32-C3
- ESP32-C3 SuperMini
- Seeed XIAO ESP32-C6
- ESP32-DevKitC V4
- LOLIN32 Lite
- Wemos D1 R32
- Cheap Yellow Display
- TTGO T-Display
- Seeed XIAO ESP32-S3
- Arduino Nano ESP32
- Arduino Nano RP2040 Connect
- Seeed XIAO RP2040
- Waveshare RP2040-Zero
- Arduino Uno R4 WiFi
The calls you will use
In the order a sketch meets them.
SevenSegmentExtended display(PIN_CLK, PIN_DIO)
Makes display, the SevenSegmentExtended object the calls below are made on.
display.begin()
Starts it up. Call it once in setup().
display.setBacklight(100)
Sets the backlight to the value you pass in. Arguments: value.
display.print("INIT")
Prints it and returns a whole number.
display.clear()
Clears it.
display.printTime(12, 34, false)
Prints the time.
display.getColonOn()
Returns the colon on as true or false.
Example: Text and a time on a TM1637 display
On the Arduino Uno R3. It runs in the browser exactly as printed.
#include "SevenSegmentTM1637.h"
#include "SevenSegmentExtended.h"
const byte PIN_CLK = 2; // define CLK pin (any digital pin)
const byte PIN_DIO = 3; // define DIO pin (any digital pin)
SevenSegmentExtended display(PIN_CLK, PIN_DIO);
void setup() {
Serial.begin(9600); // initializes the Serial connection @ 9600 baud
display.begin(); // initializes the display
display.setBacklight(100); // set the brightness to 100 %
display.print("INIT"); // display INIT on the display
delay(500);
display.clear();
display.printTime(12, 34, false);
Serial.print("colon after printTime: ");
Serial.println(display.getColonOn());
}
void loop() {}Wiring
- Arduino Uno R3 2 to Four-digit display, TM1637 CLK
- Arduino Uno R3 3 to Four-digit display, TM1637 DIO
- Arduino Uno R3 5V to Four-digit display, TM1637 VCC
- Arduino Uno R3 GND to Four-digit display, TM1637 GND
Try SevenSegmentTM1637 without installing anything
Open the example, change the sketch, and keep your version in a free account.