Having problem display number up to 10 in TM1637

I'm trying to make a time counter using 7 segment 4-digits TM1637 with millis() function and display on the module. Using It works fine until the number counts up to 10 it'll display output in A-F instead. Using TM1637 libraries. I want it to display in number, How should I fix this? and in the first digit from the left appears some weird text. Any suggestion about my code? Here is my code.

** I FIXED the time digit but it WONT APPEAR the dots in the middle**

#include <TM1637.h>
#include <TM1637Display.h>
#define CLK 2
#define DIO 3
unsigned long millisec = 0;
unsigned long sec = 0;

TM1637Display display(CLK,DIO);
TM1637 tm(CLK,DIO);


void setup() {
  
display.setBrightness(3);
Serial.begin(9600);

}


void loop() {

  millisec = millis();
  display.showNumberDecEx(millisec, 0b10000000, true , 3,2); // showNumberDecEx(number,dots,leading_zeros,length,position)
  sec = millis();
  display.showNumberDecEx(sec/1000, 0b10000000, true , 2,0);
  
  Serial.println(millisec);


  }

post your complete sketch
from the very first line to the very last line

using this method:

There is an automatic function for doing this in the Arduino-IDE
just three steps

  1. press Ctrl-T for autoformatting your code
  2. do a rightclick with the mouse and choose "copy for forum"
  3. paste clipboard into write-window of a posting

best regards Stefan

Thanks

Github hosts multiple TM1637-libaries

I looked up this demo-code

Which uses a different function the comments show what the display should show.

by the way
your loop is sending display-data at a high speed
which isn't nescessary to count up in seconds

every 500 milliseconds is suffcient

#include <TM1637.h>
#include <TM1637Display.h>
#define CLK 2
#define DIO 3
unsigned long millisec = 0;
unsigned long sec = 0;

TM1637Display display(CLK, DIO);
TM1637 tm(CLK, DIO);

boolean TimePeriodIsOver (unsigned long &periodStartTime, unsigned long TimePeriod) {
  unsigned long currentMillis  = millis();
  if ( currentMillis - periodStartTime >= TimePeriod )
  {
    periodStartTime = currentMillis; // set new expireTime
    return true;                // more time than TimePeriod) has elapsed since last time if-condition was true
  }
  else return false;            // not expired
}

unsigned long MyTestTimer = 0;                   // variables MUST be of type unsigned long


void setup() {

  display.setBrightness(3);
  Serial.begin(9600);
  Serial.println("Stetup-Start");
}


void loop() {
  millisec = millis();
  sec      = millis();

  // only send data and print if 500 millseconds have passed by
  if ( TimePeriodIsOver(MyTestTimer, 500) ) {
    display.showNumberDecEx(millisec, 0b10000000, true , 3, 2); // showNumberDecEx(number,dots,leading_zeros,length,position)
    display.showNumberDecEx(sec / 1000, 0b10000000, true , 2, 0);
    Serial.println(millisec);
  }
}

best regards Stefan

Your post was MOVED to it's current location as it is more suitable.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

NO idea what you mean by

IT WONT APPEAR THE COLON

No colon in the sourcode-code-file you posted ?
No colon on the display?

again I would start using a demo-code and then modify the demo-code in small steps to your needs.
best regards Stefan

1 Like

I mean the dots in the middle of the display

Anyway thanks for your help, I'm very new to this.