I'm working with arduino one. The robot uses two motors, two encoders, a servo, a color sensor, a button and an 8x2 lcd. Sending serial data to lcd is done by pin 13, I want the animation to work in an infinite loop while the button is not pressed. With my code, the sequence of the animation "rutina_principal()" is performed once, in the correct sequence and respecting the times, but then, it shows the characters randomly and without respecting the times.
This function is the one that gives me problems:
void rutina_principal(){
if(millis() - time1 == timeFuncion1){
ojos_Cerrados_centroSuperior();
time1 = millis();
}
if(millis() - time2 == timeFuncion2){
ojos_grandesAbiertos_centroSuperior();
time2 = millis();
}
if(millis() - time3 == timeFuncion3){
ojos_Cerrados_centroSuperior();
time3 = millis();
}
if (millis() - time4 == timeFuncion4){
ojos_grandesAbiertos_centroSuperior();
time4 = millis();
}
if (millis() - time5 == timeFuncion5){
ojos_Tristes_centroSuperior();
time5 = millis();
}
if(millis() - time6 == timeFuncion6){
ojos_Aburridos_miraDerecha_superior();
time6 = millis();
}
if(millis() - time7 == timeFuncion7){
ojos_Aburridos_miraIzquierda_superior();
time7 = millis();
}
if(millis() - time8 == timeFuncion8){
ojos_Cerrados_centroSuperior();
time8 = millis();
}}
I attach my complete code
Please help me with this
Greetings
sketch_dec07a.ino (27.6 KB)