Advertisement
claudiusmarius

ATtiny85 carte generique Neopixels

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