Bonjour je cherche à faire fonctionner ce code, c'est au niveau du clignotement
ou je n'y arrive pas quand je sélectionne 2 ou 4 au lieu de clignoter les leds
jaune et rouge restent fixe.
Merci de votre aide.
// VERT FIXE ( cas 0 )
// JAUNE FIXE ( cas 1 )
// JAUNE_CLIGNOTANT ( cas 2 )
// ROUGE FIXE ( cas 3 )
// ROUGE_CLIGNOTANT ( cas 4 )
// ARRET DE TOUTES LES LEDS ( cas 5 )
const byte pinVerte = 13 ;
const byte pinJaune = 12 ;
const byte pinRouge = 11 ;
byte etatClignotant ;
unsigned long dateDernierClignotant = 0 ;
unsigned long dateCourante = 0 ;
void setup ( )
{
pinMode ( pinVerte , OUTPUT ) ;
pinMode ( pinJaune , OUTPUT ) ;
pinMode ( pinRouge , OUTPUT ) ;
Serial . begin ( 9600 ) ;
}
void loop ( )
{
int choix_feux = Serial . read ( ) ;
switch ( choix_feux )
{
//--------------------------------------cas ( 0 )
case '0' :
Serial . println ( "led verte fixe on " ) ;
digitalWrite ( pinVerte , HIGH ) ;
// delay ( 2000 ) ;
break ;
//----------------------------------------cas ( 1 )
case '1' :
Serial . println ( "led jaune fixe on " ) ;
digitalWrite ( pinJaune , HIGH ) ;
// delay ( 2000 ) ;
break ;
//----------------------------------------cas ( 2 )
case '2' :
dateCourante = millis ( ) ;
if ( dateCourante - dateDernierClignotant > 480 )
{
dateDernierClignotant = dateCourante ;
etatClignotant = ! etatClignotant ;
digitalWrite ( pinJaune , etatClignotant ) ;
Serial . println ( "led jaune clignotante on " ) ;
}
//delay ( 2000 ) ;
break ;
//-----------------------------------------cas ( 3 )
case '3' :
Serial . println ( "led rouge fixe on " ) ;
digitalWrite ( pinRouge , HIGH ) ;
// delay ( 2000 ) ;
break ;
//-----------------------------------------cas ( 4 )
case '4' :
dateCourante = millis ( ) ;
if ( dateCourante - dateDernierClignotant > 480 )
{
dateDernierClignotant = dateCourante ;
etatClignotant = ! etatClignotant ;
digitalWrite ( pinRouge , etatClignotant ) ;
Serial . println ( "led rouge clignotante on " ) ;
}
// delay ( 2000 ) ;
break ;
//------------------------------------------cas ( 5 )
case'5':
Serial . println ( "on éteint toutes les leds " ) ;
digitalWrite ( pinVerte , LOW ) ;
digitalWrite ( pinJaune , LOW ) ;
digitalWrite ( pinRouge , LOW ) ;
break ;
//-----------------------------------------------fin
// default :
//Serial . println ( "Code de feu inconnu !" ) ;
//break ;
} }