#include <Arduino.h>
#include <TM1637TinyDisplay.h>
// Define Digital Pins
#define CLK 2
#define DIO 3
// Instantiate TM1637TinyDisplay Class
TM1637TinyDisplay display(CLK, DIO);
void setup() {
// Initialize Display
display.begin();
}
void loop() {
// Say Hello
display.showString("HELLO");
delay(1000);
// Clear Screen
display.clear();
// We can count!
for (int x = -100; x <= 100; x++) {
display.showNumber(x);
}
// Level indicator
for (int x = 0; x <= 100; x = x + 10) {
display.showLevel(x, false);
delay(20);
}
for (int x = 100; x >= 0; x = x - 10) {
display.showLevel(x, false);
delay(20);
}
// Split screen for temperature
display.showString("\xB0", 1, 3); // Degree Mark, length=1, position=3 (right)
for (int x = -90; x < 100; x++) {
display.showNumber(x, false, 3, 0); // Number, length=3, position=0 (left)
delay(10);
}
// The end
display.showString("End");
// Data from Animator Tool
//https://jasonacox.github.io/TM1637TinyDisplay/examples/7-segment-animator.html
const uint8_t ANIMATION[21][4] = {
{ 0x08, 0x00, 0x00, 0x00 }, // Frame 0
{ 0x00, 0x08, 0x00, 0x00 }, // Frame 1
{ 0x00, 0x00, 0x08, 0x00 }, // Frame 2
{ 0x00, 0x00, 0x00, 0x08 }, // Frame 3
{ 0x00, 0x00, 0x00, 0x04 }, // Frame 4
{ 0x00, 0x00, 0x00, 0x02 }, // Frame 5
{ 0x00, 0x00, 0x00, 0x01 }, // Frame 6
{ 0x00, 0x00, 0x01, 0x00 }, // Frame 7
{ 0x00, 0x01, 0x00, 0x00 }, // Frame 8
{ 0x01, 0x00, 0x00, 0x00 }, // Frame 9
{ 0x20, 0x00, 0x00, 0x00 }, // Frame 10
{ 0x10, 0x00, 0x00, 0x00 }, // Frame 11
//Decimal point rotation
{ 0x80, 0x00, 0x00, 0x01 },
{ 0x00, 0x80, 0x01, 0x00 },
{ 0x00, 0x01, 0x80, 0x00 },
{ 0x01, 0x00, 0x00, 0x80 },
{ 0x00, 0x00, 0x00, 0x00 },
{ 0x80, 0x00, 0x00, 0x01 },
{ 0x00, 0x80, 0x01, 0x00 },
{ 0x00, 0x01, 0x80, 0x00 },
{ 0x01, 0x00, 0x00, 0x80 }
};
// Display Animation sequence
display.showAnimation(ANIMATION, FRAMES(ANIMATION), TIME_MS(1000));
/* Animation Data - ABCDEFGH Map */
const uint8_t ANIMATION2[8][4] = {
{ 0x01, 0x00, 0x00, 0x00 }, // Frame 0
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 1
{ 0x00, 0x01, 0x00, 0x00 }, // Frame 2
{ 0x00, 0x01, 0x00, 0x00 }, // Frame 3
{ 0x00, 0x00, 0x01, 0x00 }, // Frame 4
{ 0x00, 0x00, 0x00, 0x00 }, // Frame 5
{ 0x00, 0x00, 0x00, 0x01 }, // Frame 6
{ 0x00, 0x00, 0x00, 0x00 } // Frame 7
};
// Display Animation sequence
display.showAnimation(ANIMATION2, FRAMES(ANIMATION), TIME_MS(1000));
delay(1000);
};