0

I decided to build a digital clock using a 4-Digit Display (TM1637) from Grove.

For that, I have been using the DigitalTube library by Grove for the TM1637 controller.

My idea is to use the two first digits of the display (left to right) to display the hour and the two last digits to display the minutes. However, managing displays is difficult and all the libraries I have found for the previously mentioned controlled can only display one number per digit.

Here you have an example: Using tm1637.display(1,2);, lets you display a "2" in the second digit (L to R), using tm1637.display(0,3); lets you display a 3 on the firt digit and etc.

As I said, I want to display the hour on the first two digits and the minutes in the two last digits. I've have readed all the examples coming with the DigitalTube library but nothing was useful.

Note: I'm using the DS3231 for managing the time with a RTC.

I don't know if you undestand my question. If not, let me know please. Arduino UNO R3.

1 Answer 1

2

Using tm1637.display(digit#, value); calls, you can display a two-digit number using division to isolate the tens digit and mod to isolate the units digit. For example, if hour and mins have hour and minute values, respectively, consider code like:

tm1637.display(0, hour/10);
tm1637.display(1, hour%10);
tm1637.display(2, mins/10);
tm1637.display(3, mins%10);

Code like the above is suitable in cases where values don't exceed 99, and where displaying a leading zero is ok.

If you don't want to display the leading zero when hour is less than 10, add an if test and blank the first digit in that case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.