LDR issues

Promedio is defined as int. Int is in the range -32768 to 32767. With 43 readings of A0, highest average yoy can get is 762. If it is higher, promedio will overflow, giving you a negative number.

Your average is calculated in setup() and never change. In loop() you have a mix of if statements using LDR value or promedio value. Looks strange to me.