Advertisement
claudiusmarius

DFT_#A116

Nov 25th, 2023
696
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.68 KB | None | 0 0
  1.  // https://www.youtube.com/c/ClaudeDufourmont
  2.   // DFT_#A116 COMMENT FAIRE CLIGNOTER A BAS COUP DES CORDONS LUMINEUX
  3.  
  4.   //#define NUM_Rub 6  // Changer cette valeur selon les besoins (doit être <= 7) car ULN2003 comporte 7 transistors seulement (sinon ajouter un 2ème ULN2003)
  5.   #define NUM_Rub 3
  6.  
  7.   //int BrochesRubans[NUM_Rub] = {D1, D2, D3, D4, D5, D6};
  8.   int BrochesRubans[NUM_Rub] = {D1, D2, D3};
  9.  
  10.   // Temps de transition et d'allumage entre chaque étape en millisecondes
  11.   unsigned long TempoTransition = 50;
  12.   unsigned long TempoAllumage = 300;
  13.   unsigned long offTime = TempoAllumage - TempoTransition;
  14.  
  15.   //**************************************************************************************************************************************************************
  16.   byte intensityLEDs = 128;                       //ATTENTION LES CORDONS DE LEDS NE COMPORTENT DE RESISTANCE - DIMINUER LA TENSION MOYENNE AVEC UNE VALEUR <= 128
  17.   //**************************************************************************************************************************************************************
  18.  
  19.   void setup()
  20.   {
  21.   // Configuation des broches PWM de sortie
  22.   for (int i = 0; i < NUM_Rub; ++i)
  23.   {
  24.   pinMode(BrochesRubans[i], OUTPUT);
  25.   }
  26.   }
  27.  
  28.   void loop()
  29.   {
  30.   for (int cord = 0; cord < NUM_Rub; ++cord)
  31.   {
  32.   // Allumage du cordon actuel
  33.   analogWrite(BrochesRubans[cord], intensityLEDs);
  34.   delay(TempoTransition);
  35.   // Extinction du cordon précédent
  36.   if (cord > 0)
  37.   {
  38.   analogWrite(BrochesRubans[cord - 1], 0);
  39.   }
  40.    delay(offTime);
  41.   }
  42.   // Extinction du dernier cordon
  43.   analogWrite(BrochesRubans[NUM_Rub - 1], 0);
  44.   delay(TempoTransition);
  45.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement