Outils pour utilisateurs

Outils du site


de_mblock_a_arduino

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
de_mblock_a_arduino [2024/09/13 10:02] mistertde_mblock_a_arduino [2024/09/26 18:17] (Version actuelle) mistert
Ligne 6: Ligne 6:
  
 {{ https://mistert-forge.site/cours/2SiCit/Arduino Vittascience corrigé.pdf | Corrigé }} {{ https://mistert-forge.site/cours/2SiCit/Arduino Vittascience corrigé.pdf | Corrigé }}
 +
 +**Feu avec gestion piéton**
 +
 +{{ https://wokwi.com/projects/409652519952763905 | Animation Wokwi }}
 +
 +{{https://www.tinkercad.com/things/gBydTi2hoNY-shiny-crift/editel?sharecode=tc4mVedVXJd9oO__L33PfsOS_REZVp4Z5-dfHhG76EU | Lien vers TinkerCad}}
 +
 +{{https://www.tinkercad.com/joinclass/FMB7KBC5P | Lien vers la classe TinkerCad}}
 +
 +<code C>
 +// C++ code
 +//
 +#define BOUTON_PIETON 3
 +#define FEU_ROUGE 5
 +#define FEU_VERT 6
 +#define FEU_ORANGE 7
 +#define FEU_PIETON 8
 +
 +int appel_pieton;
 +
 +void eteindre_feux() {
 +  digitalWrite(FEU_ROUGE, LOW);
 +  digitalWrite(FEU_VERT, LOW);
 +  digitalWrite(FEU_ORANGE, LOW);
 +  digitalWrite(FEU_PIETON, LOW);
 +}
 + 
 +void gerer_pieton() {
 +  appel_pieton = 1;
 +}
 + 
 +void gerer_feu(int pin, int temps_s) {
 +  eteindre_feux();
 +  if (pin == FEU_ROUGE and appel_pieton == 1) {
 +    digitalWrite(FEU_ROUGE, HIGH);
 +    digitalWrite(FEU_PIETON, HIGH);
 +    delay(2000);
 +    digitalWrite(FEU_PIETON, LOW); 
 +    appel_pieton = 0;
 +    temps_s -=2;
 +  } else {
 +     digitalWrite(pin, HIGH);
 +  }
 +  delay((temps_s * 1000));
 +}
 + 
 +void setup() {
 +  pinMode(BOUTON_PIETON, INPUT_PULLUP);
 +  attachInterrupt(digitalPinToInterrupt(BOUTON_PIETON), gerer_pieton, FALLING);
 +  pinMode(FEU_ROUGE, OUTPUT);
 +  pinMode(FEU_VERT, OUTPUT);
 +  pinMode(FEU_ORANGE, OUTPUT);
 +  pinMode(FEU_PIETON, OUTPUT);
 +}
 + 
 +void loop() {
 +  gerer_feu(FEU_ROUGE, 5);
 +  gerer_feu(FEU_VERT, 5);
 +  gerer_feu(FEU_ORANGE, 1);
 +}
 +</code>
  
de_mblock_a_arduino.1726221772.txt.gz · Dernière modification : 2024/09/13 10:02 de mistert