Advertisement
claudiusmarius

TestBPAUX01

May 10th, 2022
1,301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.05 KB | None | 0 0
  1. //**************************************************************************************************************************************************************************
  2. //*************************************************************** Module Télécommande RC - Carte Mega (com35) **************************************************************
  3. //**************************************************************************************************************************************************************************
  4.  
  5. #define BrocheVBuzzer 4                                                                                                 // Sortie Buzzer 5v
  6.  
  7. #define BrocheLedBleueNeutre 38                                                                                         // Broche Led bleue Neutre.........................D1
  8. #define BrocheLedVerteV1 39                                                                                             // Broche Led verte Vitesse 1......................D2
  9. #define BrocheLedJauneV2 40                                                                                             // Broche Led jaune Vitesse 2......................D3
  10. #define BrocheLedRougeAR 41                                                                                             // Broche Led rouge Marche Arrière.................D4
  11. #define BrocheLedRougeMute 42                                                                                           // Broche Led rouge Mute...........................D5
  12. #define BrocheLedJauneEclairage 43                                                                                      // Broche Led jaune Eclairage......................D6
  13. #define BrocheLedRougeAlarmeBat1 44                                                                                     // Broche Led rouge Alarme Bat1 (Télécommande).....D7
  14. #define BrocheLedRougeAlarmeBat2 45                                                                                     // Broche Led rouge Alarme Bat2 (Module Principal).D
  15.  
  16. #define BrocheBPboiteVitesse 22                                                                                         // Broche du bouton poussoir changement de Vitesse
  17. #define BrocheBPArretMoteur 23                                                                                          // Broche du bouton poussoir Arrêt Moteur
  18. #define BrocheBPCLD 24                                                                                                  // Broche du bouton poussoir CLD
  19. #define BrocheBPWarning 25                                                                                              // Broche du bouton poussoir Warning
  20. #define BrocheBPCLG 26                                                                                                  // Broche du bouton poussoir CLG
  21. #define BrocheBPEclairage 27                                                                                            // Broche du bouton poussoir Eclairage
  22. #define BrocheBPMute 28                                                                                                 // Broche du bouton poussoir Mute
  23. #define BrocheBPModeOled 29                                                                                             // Broche du bouton poussoir Mode Affichage
  24.  
  25. #define BrocheBPKlaxon 48 //=======================================================================
  26.  
  27. #define BrocheAUX1 30
  28. #define BrocheAUX2 31
  29. #define BrocheAUX3 32
  30. #define BrocheAUX4 33
  31. #define BrocheAUX5 34
  32. #define BrocheAUX6 35
  33. #define BrocheAUX7 36
  34. #define BrocheAUX8 37
  35.  
  36.  
  37.  
  38.  
  39. void setup()
  40. {
  41.   pinMode(BrocheVBuzzer, OUTPUT);                                                                                       // Configuration des ports en Entrées / Sorties
  42.  
  43.   pinMode(BrocheLedBleueNeutre, OUTPUT);
  44.   pinMode(BrocheLedVerteV1, OUTPUT);
  45.   pinMode(BrocheLedJauneV2, OUTPUT);
  46.   pinMode(BrocheLedRougeAR, OUTPUT);
  47.   pinMode(BrocheLedRougeMute, OUTPUT);
  48.   pinMode(BrocheLedJauneEclairage, OUTPUT);
  49.   pinMode(BrocheLedRougeAlarmeBat1, OUTPUT);
  50.   pinMode(BrocheLedRougeAlarmeBat2, OUTPUT);
  51.  
  52.  
  53.   pinMode(BrocheAUX1, INPUT_PULLUP);
  54.   pinMode(BrocheAUX2, INPUT_PULLUP);
  55.   pinMode(BrocheAUX3, INPUT_PULLUP);
  56.   pinMode(BrocheAUX4, INPUT_PULLUP);
  57.   pinMode(BrocheAUX5, INPUT_PULLUP);
  58.   pinMode(BrocheAUX6, INPUT_PULLUP);
  59.   pinMode(BrocheAUX7, INPUT_PULLUP);
  60.   pinMode(BrocheAUX8, INPUT_PULLUP);
  61.   pinMode(BrocheBPKlaxon, INPUT_PULLUP);
  62.  
  63.  
  64.   digitalWrite(BrocheLedBleueNeutre,LOW);
  65.   digitalWrite(BrocheLedVerteV1,LOW);
  66.   digitalWrite(BrocheLedJauneV2,  LOW);
  67.   digitalWrite(BrocheLedRougeAR,LOW);
  68.   digitalWrite(BrocheLedRougeMute,LOW);
  69.   digitalWrite(BrocheLedJauneEclairage,LOW);
  70.   digitalWrite(BrocheLedRougeAlarmeBat1,LOW);
  71.   digitalWrite(BrocheLedRougeAlarmeBat2,LOW);
  72.   digitalWrite(BrocheVBuzzer,LOW);
  73.  
  74.   //delay(800);
  75.  
  76. }
  77.  
  78. void loop()
  79. {
  80. if (digitalRead (BrocheAUX1) == LOW)
  81. {
  82. digitalWrite(BrocheLedBleueNeutre,HIGH);
  83. Buzzer (20, 0, 1);
  84. }
  85.  
  86. if (digitalRead (BrocheAUX2) == LOW)
  87. {
  88. digitalWrite(BrocheLedVerteV1,HIGH);
  89. Buzzer (20, 0, 1);
  90. }
  91.  
  92. if (digitalRead (BrocheAUX3) == LOW)
  93. {
  94. digitalWrite(BrocheLedJauneV2,HIGH);
  95. Buzzer (20, 0, 1);
  96. }
  97.  
  98. if (digitalRead (BrocheAUX4) == LOW)
  99. {
  100. digitalWrite(BrocheLedRougeAR,HIGH);
  101. Buzzer (20, 0, 1);
  102. }
  103.  
  104. if (digitalRead (BrocheAUX5) == LOW)
  105. {
  106. digitalWrite(BrocheLedRougeMute,HIGH);
  107. Buzzer (20, 0, 1);
  108. }
  109.  
  110. if (digitalRead (BrocheAUX6) == LOW)
  111. {
  112. digitalWrite(BrocheLedJauneEclairage,HIGH);
  113. Buzzer (20, 0, 1);
  114. }
  115.  
  116. if (digitalRead (BrocheAUX7) == LOW)
  117. {
  118. digitalWrite(BrocheLedRougeAlarmeBat1,HIGH);
  119. Buzzer (20, 0, 1);
  120. }
  121.  
  122. if (digitalRead (BrocheAUX8) == LOW)
  123. {
  124. digitalWrite(BrocheLedRougeAlarmeBat2,HIGH);
  125. Buzzer (20, 0, 1);
  126. }
  127.  
  128. if (digitalRead (BrocheBPKlaxon) == LOW)
  129. {
  130. digitalWrite(BrocheVBuzzer, HIGH);
  131. }
  132.  
  133. delay(800);
  134.   digitalWrite(BrocheLedBleueNeutre,LOW);
  135.   digitalWrite(BrocheLedVerteV1,LOW);
  136.   digitalWrite(BrocheLedJauneV2,  LOW);
  137.   digitalWrite(BrocheLedRougeAR,LOW);
  138.   digitalWrite(BrocheLedRougeMute,LOW);
  139.   digitalWrite(BrocheLedJauneEclairage,LOW);
  140.   digitalWrite(BrocheLedRougeAlarmeBat1,LOW);
  141.   digitalWrite(BrocheLedRougeAlarmeBat2,LOW);
  142.   digitalWrite(BrocheVBuzzer,LOW);
  143.  
  144. }  
  145.  
  146. //*************************************************************************************************************************************************************************
  147. //*** Fonction Buzzer *****************************************************************************************************************************************************
  148. //*************************************************************************************************************************************************************************
  149. void Buzzer (int TempsH, int TempsL, int nb)
  150. {
  151.   //if (mute) {return;}                                                                                                 // Sort si la fonction mute est activée
  152.  
  153.   for (int x = 1; x <= nb; x++)
  154.   {
  155.     digitalWrite(BrocheVBuzzer, HIGH);
  156.     delay (TempsH);
  157.     digitalWrite(BrocheVBuzzer, LOW);
  158.     delay (TempsL);
  159.   }
  160. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement