I modified the "lumiere" function according to your recommendations:
void lumiere()
{
AV = analogRead(photoAV);
GA = analogRead(photoGA);
DR = analogRead(photoDR);
if(AV > GA && AV > DR){
Serial.print('H');
digitalWrite(led10, LOW);
digitalWrite(led12, LOW);
moteur(0, false, 0, false, 500);
}
else{
digitalWrite(led10, HIGH);
digitalWrite(led12, LOW);
Serial.print('L');
while (Serial.available()) {
// read the oldest byte in the serial buffer:
incomingByte = Serial.read();
// if it's a capital H (ASCII 72), turn motors in one direction:
if (incomingByte == 'H') {
moteuravance(255, false, 0, true);
}
else if (incomingByte == 'L') {
moteuravance(0, true, 255, false);
}
}
}
}
and it works.... Thanks a lot!