7-segment display TM1637 on Arduino
FunduinoLast updated on
Ziffern anzeigen, blinken lassen und einen Timer bauen
The module and its colors
Install library
Part 1: Display a single digit
Part 1: Display a single digit
#include <TM1637Display.h>
// Define the pins for CLK and DIO
#define CLK 4
#define DIO 5
// Create a display object
TM1637Display display(CLK, DIO);
void setup()
{
// Set the display brightness (0 to 7)
display.setBrightness(7);
// Clear the display
display.clear();
// Display a digit (5 in this case)
display.showNumberDec(5, false, 1, 0);
}
void loop()
{
// Nothing else to do in loop: The display was already set in setup.
}Part 2: Display four digits and make them blink
Part 2: Display four digits and make them blink
#include <TM1637Display.h>
#define CLK 4
#define DIO 5
TM1637Display display(CLK, DIO);
void setup()
{
display.setBrightness(7);
display.clear();
}
void loop()
{
// Display the number 5678 for one second
display.showNumberDec(5678);
delay(1000);
// Clear the display for 500 milliseconds - this makes it blink
display.clear();
delay(500);
}Part 3: Programming a timer
Part 3: Programming a timer
#include <TM1637Display.h>
// Timer starting value
int x = 0;
#define CLK 4
#define DIO 5
TM1637Display display(CLK, DIO);
void setup()
{
display.setBrightness(7);
display.clear();
}
void loop()
{
// Display the current count
display.showNumberDec(x);
delay(800);
// Increment the count by 1
x = x + 1;
// Clear briefly so the change is visible
display.clear();
delay(200);
}Rate the instructions