The way you describes it makes me think the LED is on when pin 5 is LOW.
First, for readability, you should give your pins a name and, since your LED is (probably) connected between 5V and the Arduino pin 5, you should give the pin states (HIGH and LOW) a name too :
#define LedPin 5
#define LedON LOW
#define LedOFF HIGH
.
.
.
void setup()
{
.
.
.
pinMode(LedPin, OUTPUT); // self explanatory
// digitalWrite(5, LOW); // I think you're wrong here, should be HIGH !
digitalWrite(LedPin, LedOFF); // Is it HIGH or LOW ? Who cares, it's OFF anyway
}
Now for the if (horaAtual == horaAlimentacao1 && minutoAtual == minutoAlimentacao1){} statement : this condition will remain true for one entire minute. As the statement requires 20 seconds to execute, it will be entered 3 times in a row. To enter it only once, you need a flag (or boolean) :
//parâmetros de horário que serão atualizados
int horaAtual, minutoAtual;
bool LedCylceDone = false; // <-- NEW
.
.
.
void loop()
{
.
.
.
if(!LedCylceDone && horaAtual == horaAlimentacao1 && minutoAtual == minutoAlimentacao1)
{
digitalWrite((LedPin, LedON);
delay(20000);
digitalWrite((LedPin, LedOFF);
LedCylceDone = true;
}
if(LedCylceDone && (horaAtual != horaAlimentacao1 || minutoAtual != minutoAlimentacao1))
{
LedCylceDone = false; // Reset the flag once the timing condition is over
}
}
It is already working but when the selected time arrives it works but while the led is on the clock freezes and only works again when you turn off the led
I made comments about the way I think the LED is connected. We need an answer about that. Plus your code correctly indented and posted with manually added cpp tag rather than default tag to add colors that help for readability.
Default tag :