#include <TimerOne.h>

//const int Pin_Led = 13;
int pin;
void setup() {
  // put your setup code here, to run once:
  Timer1.initialize(1000);  // 1ms
  Timer1.attachInterrupt( Systick_Handler );

  pinMode(7, OUTPUT);
  pinMode(6, OUTPUT);
  MdT_Disparar(0, 2, 1, Encender_Led,7);
  MdT_Disparar(1, 4, 1, Encender_Led,6);
}

void loop() {
  // put your main code here, to run repeatedly:
  MdT_Analizar();
}

void Systick_Handler(void)
{
  static int Estado = 0;
  static int Divisor = 0;

  Divisor++;
  if(Divisor > 1000)
  {
    Divisor = 0;
    
    MdT_Descontar();
  }
}

void Encender_Led()
{
  static uint8_t Estado = 0;

  if(Estado)
  {
    digitalWrite(pin, 0);
    Estado = 0;
  }
  else
  {
    digitalWrite(pin, 1);
    Estado = 1;
  }
}



#define CANTIDAD_TIMERS 8

typedef struct
{
  uint32_t  Tiempo; 
  uint32_t  Tiempo_Repeticion;
  uint8_t   Fin;
  void      (*Func)(void);
  uint8_t   Led_Pin;
}Struct_Timer;

Struct_Timer Timer[CANTIDAD_TIMERS];

void MdT_Descontar(void)
{
  uint8_t i;

  for(i = 0 ; i < CANTIDAD_TIMERS ; i++)
  {
    if(Timer[i].Tiempo > 0)
    {
      Timer[i].Tiempo--;
      if(Timer[i].Tiempo == 0)
      {
        Timer[i].Fin = 1;
        Timer[i].Tiempo = Timer[i].Tiempo_Repeticion;
      }
    }
  }
}

void MdT_Disparar(uint8_t Indice, uint32_t Tiempo, uint32_t Tiempo_Repeticion, void (*func)(void), uint8_t Led_pin)
{
  Timer[Indice].Tiempo = Tiempo;
  Timer[Indice].Tiempo_Repeticion = Tiempo_Repeticion;
  Timer[Indice].Fin = 0;
  Timer[Indice].Func = func;
  Timer[Indice].Led_Pin = Led_pin;
}

void MdT_Analizar(void)
{
  uint8_t i;

  for(i = 0 ; i < CANTIDAD_TIMERS ; i++)
  {
    if(Timer[i].Fin == 1)
    {
      Timer[i].Fin = 0;
      pin = Timer[i].Led_Pin;
      Timer[i].Func();
    }
  }
}
uno:A5.2
uno:A4.2
uno:AREF
uno:GND.1
uno:13
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:1
uno:0
uno:IOREF
uno:RESET
uno:3.3V
uno:5V
uno:GND.2
uno:GND.3
uno:VIN
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
led1:A
led1:C
led2:A
led2:C
r1:1
r1:2
r2:1
r2:2