Advertisement
Kamanzi

4strips

Nov 28th, 2020
3,369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 9.15 KB | None | 0 0
  1. //================================================================================================================================================================
  2.   //    COMMUTATION ANIMATION 16 possibiliés fonction des 4entrées numériques                                        
  3.   //    FONCTIONNEMENT actuellement sur matrice 25 LEDS mais nous pouvons commander des strips avec un nombre de LEDS < 110
  4.   //    Il s'agit d'une plaquette générique et donc nous avons libre choix de placer pour chaque fonction sélectionnée en fonction des 4 entrées et de la table de
  5.   //    vérité le code d'animation souhaité.
  6.   //    Plaquette_ATtiny85_generique_Neopixels01
  7.   //    DUFOURMONT Le 25/11/2020
  8.   //    claude.dufourmont@laposte.net
  9.   //    YouTube Channel : https://www.youtube.com/channel/UCvr9eb05lJow6N7m3SKqvNw
  10.   //================================================================================================================================================================
  11.  
  12.                             //====================================================================================  
  13.                                 //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  14.                                 //                            109 LEDs au MAXIMUN                            >    
  15.                                 //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  16.                             //====================================================================================  
  17.                            
  18.   #include <Adafruit_NeoPixel.h>
  19.   #define PIN1      0
  20.  
  21.   #define E1 1
  22.   #define E2 2
  23.   #define E3 3
  24.   #define E4 4
  25.  
  26.   #define N_LEDS1 109
  27.  
  28.   bool etatE1 = LOW;
  29.   bool etatE2 = LOW;
  30.   bool etatE3 = LOW;
  31.   bool etatE4 = LOW;
  32.  
  33.   Adafruit_NeoPixel strip1(N_LEDS1, PIN1, NEO_GRB + NEO_KHZ800);
  34.  
  35.   void setup()
  36.   {
  37.                               //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  38.                               // Les pinMode ne sont pas déclarés car sur l'ATtiny85 c'est INPUT d'office     >
  39.                               //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  40.  
  41.   strip1.begin();
  42.   strip1.clear();
  43.   strip1.setBrightness(4);
  44.   strip1.show();
  45.   }
  46.  
  47.   void loop ()
  48.   {
  49.   digitalRead (E1);
  50.   digitalRead (E2);
  51.   digitalRead (E3);
  52.   digitalRead (E4);
  53.  
  54.   //========================================================================DETERMINATION DES ETATS LOGIQUE -----DEBUT-----===============================================================
  55.   if (  digitalRead (E1) == HIGH)
  56.   {
  57.   etatE1 = HIGH;
  58.   }
  59.   else
  60.   {
  61.   etatE1 = LOW;
  62.   }
  63.    
  64.   if (  digitalRead (E2) == HIGH)
  65.   {
  66.   etatE2 = HIGH;
  67.   }
  68.   else
  69.   {
  70.   etatE2 = LOW;
  71.   }
  72.  
  73.   if (  digitalRead (E3) == HIGH)
  74.   {
  75.   etatE3 = HIGH;
  76.   }
  77.   else
  78.   {
  79.   etatE3 = LOW;
  80.   }
  81.  
  82.   if (  digitalRead (E4) == HIGH)
  83.   {
  84.   etatE4 = HIGH;
  85.   }
  86.   else
  87.   {
  88.   etatE4 = LOW;
  89.   }
  90.   //========================================================================DETERMINATION DES ETATS LOGIQUE -----FIN-----===============================================================
  91.  
  92.  //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  93.  
  94.  //========================================================================TABLE DE VERITE -----DEBUT-----==============================================================================
  95.  if (etatE1 == LOW && etatE2 == LOW && etatE3 == LOW && etatE4 == LOW)
  96.  {
  97.   animation00 ();
  98.  }
  99.  
  100.   if (etatE1 == LOW && etatE2 == LOW && etatE3 == LOW && etatE4 == HIGH)
  101.  {
  102.   animation01 ();
  103.  }
  104.  
  105.   if (etatE1 == LOW && etatE2 == LOW && etatE3 == HIGH && etatE4 == LOW)
  106.  {
  107.   animation02 ();
  108.  }
  109.  
  110.   if (etatE1 == LOW && etatE2 == LOW && etatE3 == HIGH && etatE4 == HIGH)
  111.  {
  112.   animation03 ();
  113.  }
  114.  
  115.   if (etatE1 == LOW && etatE2 == HIGH && etatE3 == LOW && etatE4 == LOW)
  116.  {
  117.   animation04 ();
  118.  }
  119.  
  120.  if (etatE1 == LOW && etatE2 == HIGH && etatE3 == LOW && etatE4 == HIGH)
  121.  {
  122.   animation05 ();
  123.  }
  124.  
  125.   if (etatE1 == LOW && etatE2 == HIGH && etatE3 == HIGH && etatE4 == LOW)
  126.  {
  127.   animation06 ();
  128.  }
  129.  
  130.    if (etatE1 == LOW && etatE2 == HIGH && etatE3 == HIGH && etatE4 == HIGH)
  131.  {
  132.   animation07 ();
  133.  }
  134.  
  135.   if (etatE1 == HIGH && etatE2 == LOW && etatE3 == LOW && etatE4 == LOW)
  136.  {
  137.   animation08 ();
  138.  }
  139.  
  140.   if (etatE1 == HIGH && etatE2 == LOW && etatE3 == LOW && etatE4 == HIGH)
  141.  {
  142.   animation09 ();
  143.  }
  144.  
  145.   if (etatE1 ==HIGH && etatE2 == LOW && etatE3 == HIGH && etatE4 == LOW)
  146.  {
  147.   animation10 ();
  148.  }
  149.  
  150.   if (etatE1 == HIGH && etatE2 == LOW && etatE3 == HIGH && etatE4 == HIGH)
  151.  {
  152.   animation11 ();
  153.  }
  154.  
  155.   if (etatE1 == HIGH && etatE2 == HIGH && etatE3 == LOW && etatE4 == LOW)
  156.  {
  157.   animation12 ();
  158.  }
  159.  
  160.  if (etatE1 == HIGH && etatE2 == HIGH && etatE3 == LOW && etatE4 == HIGH)
  161.  {
  162.   animation13 ();
  163.  }
  164.  
  165.   if (etatE1 == HIGH && etatE2 == HIGH && etatE3 == HIGH && etatE4 == LOW)
  166.  {
  167.   animation14 ();
  168.  }
  169.  
  170.  if (etatE1 == HIGH && etatE2 == HIGH && etatE3 == HIGH && etatE4 == HIGH)
  171.  {
  172.   animation15 ();
  173.  }
  174.  
  175.   }
  176.   void animation00 ()
  177.   {
  178.   strip1.clear();
  179.   strip1.show();
  180.   strip1.setPixelColor(0, 255, 0, 0);
  181.   strip1.show ();
  182.   delay(1000);
  183.   }
  184.  
  185.   void animation01 ()
  186.   {
  187.   strip1.clear();
  188.   strip1.show();
  189.   delay(1000);
  190.   for ( int i = 0; i<5; i++)
  191.   {
  192.   strip1.setPixelColor(i, 255, 0, 0);
  193.   strip1.show ();
  194.   }
  195.   delay(1000);
  196.   for ( int i = 5; i<10; i++)
  197.   {
  198.   strip1.setPixelColor(i,0, 255, 0);
  199.   strip1.show ();
  200.   }
  201.   delay(1000);
  202.   for ( int i = 10; i<15; i++)
  203.   {
  204.   strip1.setPixelColor(i, 0, 0, 255);
  205.   strip1.show ();
  206.   }
  207.   delay(1000);
  208.   for ( int i = 15; i<20; i++)
  209.   {
  210.   strip1.setPixelColor(i, 100, 40, 255);
  211.   strip1.show ();
  212.   }
  213.   delay(1000);
  214.   for ( int i = 20; i<25; i++)
  215.   {
  216.   strip1.setPixelColor(i, 255, 255, 255);
  217.   strip1.show ();
  218.   }
  219.   delay(1000);
  220.   strip1.clear ();
  221.   strip1.show ();
  222.   delay(1000);
  223.   }
  224.  
  225.   void animation02 ()
  226.   {
  227.   strip1.clear();
  228.   strip1.show();
  229.   delay(1000);
  230.   for ( int i = 0; i<5; i= i+2)
  231.   {
  232.   strip1.setPixelColor(i, 255, 0, 0);
  233.   strip1.show ();
  234.   }
  235.   delay(1000);
  236.   for ( int i = 5; i<10; i= i+2)
  237.   {
  238.   strip1.setPixelColor(i,0, 255, 0);
  239.   strip1.show ();
  240.   }
  241.   delay(1000);
  242.   for ( int i = 10; i<15; i= i+2)
  243.   {
  244.   strip1.setPixelColor(i, 0, 0, 255);
  245.   strip1.show ();
  246.   }
  247.   delay(1000);
  248.   for ( int i = 15; i<20; i= i+2)
  249.   {
  250.   strip1.setPixelColor(i, 100, 40, 255);
  251.   strip1.show ();
  252.   }
  253.   delay(1000);
  254.   for ( int i = 20; i<25; i= i+2)
  255.   {
  256.   strip1.setPixelColor(i, 255, 255, 255);
  257.   strip1.show ();
  258.   }
  259.   delay(1000);
  260.   strip1.clear ();
  261.   strip1.show ();
  262.   delay(1000);
  263.   }
  264.  
  265.   void animation03 ()
  266.   {
  267.   strip1.clear();
  268.   strip1.show();
  269.   delay(1000);
  270.   for ( int i = 2; i<23; i= i+5)
  271.   {
  272.   strip1.setPixelColor(i, 255, 0, 0);
  273.   strip1.show ();
  274.   }
  275.   delay(1000);
  276.   for ( int i = 2; i<23; i= i+5)
  277.   {
  278.   strip1.setPixelColor(i,0, 255, 0);
  279.   strip1.show ();
  280.   }
  281.   delay(1000);
  282.   strip1.clear ();
  283.   strip1.show ();
  284.   delay(1000);
  285.   }
  286.  
  287.   void animation04 ()
  288.   {
  289.   strip1.clear();
  290.   strip1.show();
  291.   delay(1000);
  292.   for ( int i = 10; i<15; i++)
  293.   {
  294.   strip1.setPixelColor(i, 0, 0, 255);
  295.   strip1.show ();
  296.   }
  297.   delay(300);
  298.   for ( int i = 10; i<15; i++)
  299.   {
  300.   strip1.setPixelColor(i,0, 255, 0);
  301.   strip1.show ();
  302.   }
  303.   delay(300);
  304.   strip1.clear ();
  305.   strip1.show ();
  306.   delay(1000);
  307.   }
  308.  
  309.   void animation05 ()
  310.   {
  311.   strip1.clear();
  312.   strip1.show();
  313.   strip1.setPixelColor(5, 0, 255, 0);
  314.   strip1.show ();
  315.   delay(1000);
  316.   }
  317.  
  318.   void animation06 ()
  319.   {
  320.   strip1.clear();
  321.   strip1.show();
  322.   strip1.setPixelColor(6, 6,0, 255);
  323.   strip1.show ();
  324.   delay(1000);
  325.   }
  326.  
  327.   void animation07 ()
  328.   {
  329.   strip1.clear();
  330.   strip1.show();
  331.   strip1.setPixelColor(7, 0, 255, 100);
  332.   strip1.show ();
  333.   delay(1000);
  334.   }
  335.  
  336.   void animation08 ()
  337.   {
  338.   strip1.clear();
  339.   strip1.show();
  340.   strip1.setPixelColor(8, 255, 255, 0);
  341.   strip1.show ();
  342.   delay(1000);
  343.   }
  344.    
  345.   void animation09 ()
  346.   {
  347.   strip1.clear();
  348.   strip1.show();
  349.   strip1.setPixelColor(9, 40, 255, 100);
  350.   strip1.show ();
  351.   delay(1000);
  352.   }
  353.  
  354.   void animation10 ()
  355.   {
  356.   strip1.clear();
  357.   strip1.show();
  358.   strip1.setPixelColor(10, 0, 255, 0);
  359.   strip1.show ();
  360.   delay(1000);
  361.   }
  362.  
  363.   void animation11 ()
  364.   {
  365.   strip1.clear();
  366.   strip1.show();
  367.   strip1.setPixelColor(11, 255, 255, 0);
  368.   strip1.show ();
  369.   delay(1000);
  370.   }
  371.    
  372.   void animation12 ()
  373.   {
  374.   strip1.clear();
  375.   strip1.show();
  376.   strip1.setPixelColor(12, 0, 255, 255);
  377.   strip1.show ();
  378.   delay(1000);
  379.   }
  380.  
  381.   void animation13 ()
  382.   {
  383.   strip1.clear();
  384.   strip1.show();
  385.   strip1.setPixelColor(13, 0, 255, 0);
  386.   strip1.show ();
  387.   delay(1000);
  388.   }
  389.  
  390.   void animation14 ()
  391.   {
  392.   strip1.clear();
  393.   strip1.show();
  394.   strip1.setPixelColor(14, 100, 255, 100);
  395.   strip1.show ();
  396.   delay(1000);
  397.   }
  398.  
  399.   void animation15 ()
  400.   {
  401.   strip1.clear();
  402.   strip1.show();
  403.   strip1.setPixelColor(5, 255, 255, 255);
  404.   strip1.show ();
  405.   delay(1000);
  406.   }
  407.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement