Mini Défi #5 : Chenillard 4 lampes Résolu
🎮 Objectif :
Créer un petit programme qui fait défiler 4 lampes en séquence, à la manière d’un chenillard lumineux.
🔧 Cahier des charges :
-
Les lampes s’allument une par une, toutes les 500 ms
-
Le cycle recommence en boucle : lampe 1 → lampe 2 → lampe 3 → lampe 4 → retour à 1
-
Un bouton permet de démarrer / arrêter le chenillard
🧠 Consignes :
-
Propose ta solution en Structured Text, Ladder, ou même en pseudo-code
-
Bonus : propose une version "aller-retour" (effet va-et-vient)
💬 N'hésite pas à poster ton raisonnement pas à pas ou une capture de ton projet.
📅 Solution officielle lundi avec validation d'une réponse🏅
Réponses
Julien
None
SebastienLL
None
DECLATION DES VARIABLES ENTREES SORTIES
FM_BOUTON TYPE R_TRIG BOUTON TYPE BOOL LAMPE1 TYPE BOOL
FD_LAMPE1 TYPE F_TRIG LAMPE2 TYPE BOOL
FD_LAMPE2 TYPE F_TRIG LAMPE3 TYPE BOOL
FD_LAMPE3 TYPE F_TRIG LAMPE4 TYPE BOOL
FD_LAMPE4 TYPE F_TRIG
TP_LAMPE1 TYPE TP
TP_LAMPE2 TYPE TP
TP_LAMPE3 TYPE TP
TP_LAMPE4 TYPE TP
PROGRAMME
FM_BOUTON (BOUTON);
FD_LAMPE1 (LAMPE1);
FD_LAMPE2 (LAMPE2);
FD_LAMPE3 (LAMPE3);
FD_LAMPE4 (LAMPE4);
TP_LAMPE1( FM_BOUTON.Q OR FD_LAMPE4.Q, t#500ms );
LAMPE1:=TP_LAMPE1.Q;
TP_LAMPE2(FD_LAMPE1.Q, t#500ms);
LAMPE2:=TP_LAMPE2.Q;
TP_LAMPE3(FD_LAMPE2.Q, t#500ms);
LAMPE3:=TP_LAMPE3.Q;
TP_LAMPE4(FD_LAMPE3.Q, t#500ms);
LAMPE4:=TP_LAMPE4.Q;
IF NOT BOUTON THEN
LAMPE1:=false;
LAMPE2:=false;
LAMPE3:=false;
LAMPE4:=false;
END_IF;

Maitre du Jeu
"One who knows nothing can understand nothing" - Master Xehanort
📅 Correction du Mini-Défi #5 : Chenillard 4 lampes
Ce mini-défi vous a bien chauffé les neurones 💡
C’était simple en apparence, mais très bon pour exercer votre logique : tempo, séquence, mémoire, redémarrage propre…
🎯 Rappel des exigences :
-
4 lampes qui s’allument une par une
-
Une nouvelle lampe toutes les 500 ms
-
Reboucle à l’infini
-
Bouton Start/Stop pour activer/désactiver le cycle
-
✅ Exemple de solution en Structured Text :
⚙️ Variante Ladder (simplifiée) :
Tu peux aussi utiliser 4 temporisations successives avec des contacts mémoire ou une bascule cyclique (CTU + RESET).