//TM1637_Arduino by avishorp
#include <Arduino.h>
#include <TM1637Display.h>
// Module connection pins (Digital Pins)
#define CLK 3
#define DIO 5
// The amount of time (in milliseconds) between tests
#define TEST_DELAY 2000
const uint8_t SEG_DONE[] = {
SEG_B | SEG_C | SEG_D | SEG_E | SEG_G, // d
SEG_A | SEG_B | SEG_C | SEG_D | SEG_E | SEG_F, // O
SEG_C | SEG_E | SEG_G, // n
SEG_A | SEG_D | SEG_E | SEG_F | SEG_G // E
};
TM1637Display display(CLK, DIO);
void setup()
{
Serial.begin(115200);
Serial.println(F("starting up"));
}
void loop()
{
Serial.println(F("loop start"));
uint8_t data[] = { 0xff, 0xff, 0xff, 0xff };
uint8_t blank[] = { 0x00, 0x00, 0x00, 0x00 };
display.setBrightness(0x0f);
// All segments on
display.setSegments(data);
delay(TEST_DELAY);
display.clear();
int k=7;
display.setBrightness(k);
// Run through all the dots
//! Display a decimal number, with dot control
//!
//! Display the given argument as a decimal number. The dots between the digits (or colon)
//! can be individually controlled.
//!
//! @param num The number to be shown
//! @param dots Dot/Colon enable. The argument is a bitmask, with each bit corresponding to a dot
//! between the digits (or colon mark, as implemented by each module). i.e.
//! For displays with dots between each digit:
//! * 0.000 (0b10000000)128
//! * 00.00 (0b01000000) 64
//! * 000.0 (0b00100000) 32
//! * 0.0.0.0 (0b11100000) 224
//! For displays with just a colon:
//! * 00:00 (0b01000000) 64
//! For displays with dots and colons colon:
//! * 0.0:0.0 (0b11100000) 224
//! @param leading_zero When true, leading zeros are displayed. Otherwise unnecessary digits are
//! blank. NOTE: leading zero is not supported with negative numbers.
//! @param length The number of digits to set. The user must ensure that the number to be shown
//! fits to the number of digits requested (for example, if two digits are to be displayed,
//! the number must be between 0 to 99)
//! @param pos The position of the most significant digit (0 - leftmost, 3 - rightmost)
//void showNumberDecEx(int num, uint8_t dots = 0, bool leading_zero = false, uint8_t length = 4, uint8_t pos = 0);
Serial.println(F("128"));
display.showNumberDecEx(3333, 128, true,4,0);
delay(TEST_DELAY);
Serial.println(F("64"));
display.showNumberDecEx(333, 64, true,4,0);
delay(TEST_DELAY);
Serial.println(F("32"));
display.showNumberDecEx(33, 32, true,4,0);
delay(TEST_DELAY);
Serial.println(F("224"));
display.showNumberDecEx(3, 224, true,4,0);
delay(TEST_DELAY);
// Done!
Serial.println(F("done for now..."));
display.setSegments(SEG_DONE);
}