countdown

Hi, I’m trying to learn and understand in an autodidactic way, it’s not easy, and that’s why I ask for help with this project I want to do, it’s a timer down counter. The code will remove it from the page prometec. And I would need help with the countdown, the problem is that I am missing something, and I can not make myself discard the minutes.


int Min=05; //Cambiar este dato para la hora
int Seg=59; //Cambiar este dato para los min
byte Digit[10][7]=
{ //a b c d e f g
{1,1,1,1,1,1,0}, //0
{0,1,1,0,0,0,0}, //1
{1,1,0,1,1,0,1}, //2
{1,1,1,1,0,0,1}, //3
{0,1,1,0,0,1,1}, //4
{1,0,1,1,0,1,1}, //5
{1,0,1,1,1,1,1}, //6
{1,1,1,0,0,0,0}, //7
{1,1,1,1,1,1,1}, //8
{1,1,1,1,0,1,1} //9
};

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setup() {

for(int i=2;i<=13;i++)
{
pinMode(i,OUTPUT);
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void loop() {
int n = millis() / 1000 ; // Lo pasamos a segundos
int segundos = n % 60 ;
int minutos = n / 60 ;

int k = minutos * 100 - segundos;
k=k+(Min*100)+Seg;
CalculaDigitos(k) ;

}
void Display(int pos,int N)
{
digitalWrite(9 ,HIGH); // Apaga todos los digitos
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
digitalWrite(12,HIGH);
for (int j=0;j<=6;j++)
{
int valor=Digit[N][j];
digitalWrite(j+2,valor);

}

digitalWrite(pos+9,LOW);

}

void CalculaDigitos( int Num)
{
int Digit0 = Num %10 ;
int Digit1 = (Num % 100) / 10;
int Digit2 = (Num % 1000) / 100;
int Digit3 = (Num / 1000);

Display(3 , Digit3);
Display(2 , Digit2);
Display(1 , Digit1);
Display(0 , Digit0);

}


When you post code, please use code tags.

Please see this link. Item #7 describes code tags. https://forum.arduino.cc/index.php?topic=148850.0

Also, it looks like your code has several problems. It is probably best if you take care of them one at a time. First, try simplifying your project. Just for now, get rid of the minutes. Try using only one digit. Can you make a 9-second countdown? (9, 8, 7, ..., 1, 0)

int n = millis() / 100 ; // Lo pasamos a segundos

There are 1000 milliseconds in one second, not 100.

PaulS: int n = millis() / 100 ; // Lo pasamos a segundos

There are 1000 milliseconds in one second, not 100.

Thank you, I had done this so that I could see the fast