Skip to content

Another example for the TM1638 library #2

@SergK-2022

Description

@SergK-2022

Единственный пример не дает полного представления о библиотеке!
Хочу предложить добавить пример простых часов, которые отсчитывают время с момента запуска.

A single example does not give a complete picture of the library!
I would like to suggest adding an example of a simple clock that counts time from the moment it is launched.

#include <TM1638.h>
// Библиотека https://github.com/dvarrel/TM1638 1.0.1 

TM1638 module(2, 3, 4); //pin settings CLK, DIO, STB
byte time[9]; 

void setup()
{
  module.reset();
}
void loop()
{
char *separator = "-";
for(time[0]=0;time[0]<3;time[0]++)
{
  for(time[1]=0;time[1]<10;time[1]++)
  {
    for(time[3]=0;time[3]<6;time[3]++)
    {
      for(time[4]=0;time[4]<10;time[4]++)
      {
        for(time[6]=0;time[6]<6;time[6]++)
        {
          for(time[7]=0;time[7]<10;time[7]++)
         {
          delay(1000); 
          //module.displayVal(0, 8);//tens hours
          module.displayVal(7, time[0]);//tens hours
          // The numbering is in reverse order - the first digit has the ordinal number 7, the last one - 0
          module.displayVal(6, time[1]);//hours
          module.displayDig(5, 0b01000000);//separator "-"
          // The character to be output is the segments in reverse order, in this case it is "G"
          module.displayVal(4, time[3]);//tens mins
          module.displayVal(3, time[4]);//mins
          module.displayDig(2, 0b01000000);//separator "-"
          module.displayVal(1, time[6]);//tens secs
          module.displayVal(0, time[7]);//secs
          
        }
       }
      }
    }
  }
}

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions