Bonjour à tous,
Je suis dans une nouvelle phase de programmation de mon automate d'orgue de barbarie ( le faire parler avec synchronisation de la bouche ), après une programmation réaliste de mouvements de tête ,yeux, bouche très fluide.
Le programme devenant conséquent, je souhaite faire des sous programmes façon " GOSUB / RETURN " en Basic.
Ne connaissant pas encore toutes les riches subtilités du langages Arduino, j'ai besoin de votre aide.
Comment faire des sous programmes lorsque l'on a besoin de répète un grand nombre fois la même routine ?
J'ai essayé de faire un programme d'essai à base de " GOTO " ( Oui je sais ce n'est pas bien !! ), mais en plus il tourne mais ne fais pas ce que je lui demande.
Pour ne pas mourir idiot, merci de me dire pourquoi.
D'avance merci
Didier ( Dijon )
//Programmation avec sous programme 27 Mai 2014
int a;
void setup()
{
Serial.begin(19200);
}
void loop()
{
label:
delay(2000);
//a=3;
a=random(1,5);
Serial.println (" ");
Serial.println (a);
Serial.println (" ");
if (a=1)
{
goto Cmd1;
}
if (a=2)
{
goto Cmd2;
}
if (a=3)
{
goto Cmd3;
}
Cmd2:
Serial.println (" ");
Serial.print (" Cmd 2 : ");
Serial.println (a);
goto label;
Cmd1:
Serial.println (" ");
Serial.print (" Cmd 1 : ");
Serial.println (a);
goto label;
Cmd3:
Serial.println (" ");
Serial.print (" Cmd 3 : ");
Serial.println (a);
goto label;
}