Fórum témák

» Több friss téma
Fórum » Színes, animált kijelzésű hangfrekvenciás spektrum-analizátor
Lapozás: OK   1 / 2
(#) dB_Thunder hozzászólása Márc 3, 2021 /
 
Sziasztok!

Direkt szeretnék ennek a projektnek külön témát!
Az alap ötlet PLATINUM által közzétett videókból származik, eldöntöttem nekem is kell egy ilyen!
Mivel a megvalósítás, a fizikai méret, a költségvetés, programok, animációk lehetősége szinte határtalan, én több verziót, kivitelt is összeszedtem. Ezeket majd külön hozzászólásokban felteszem!


A készítő WS2812 led szalaggal, Arduiono Megával, és MSGEQ7 ic-vel építkezett.
Verziótól függően 7, vagy 14 sávos, Led oszlopok magassága a szerző szerint max 20 led lehet, de úgy vettem észre kisebb módosítássokkal több is!

Költségvetés: kb 60e Ft-tól megvehető
A mechanikai kivitelezés költségeit most nem nézem, mert számtalan lehetőség van rá!
Led szalag, magyarországi forrásból a 60LED/m szalag vagy 27ezerFT! Érdemes kínából rendelni.
MSGEQ7, sok a hamisítvány! Rögtön rendeltem az ebay-on 8db hamisat, szerencsére visszafizették az árát!
Egy magyar forrás találtam, nem olcsó, de legalább nem hamis ic-t kaptam!
A hozzászólás módosítva: Márc 3, 2021
(#) dB_Thunder válasza dB_Thunder hozzászólására (») Márc 3, 2021 /
 
Szóval MSGEQ beszerzés: Ardushop
Arduinót is érdemes kínából megvenni, de ez nekem polcon volt.
Használ a projekt még egy frekvencia generátor panelt is, ez is filléres kínában. De ez csak a 14 sávos verzióhoz kell!
A hozzászólás módosítva: Márc 3, 2021
(#) dB_Thunder válasza dB_Thunder hozzászólására (») Márc 3, 2021 /
 
Kezdjük kicsit messzebb a hasonló projektek bemutatását!
Ezek a projektek vagy a FASTLED, vagy a NEOPIXEL lib-at használják a led szalag vezérléséhez, érdemes mind2 letölteni.

Én magam nem próbáltam ki egyik kódját sem, nem túl komoly animációk jellemzik, de a 42 valós sáv érdekesen hangzik!
generatorlabs
Nincs minden dokumentálva, szájba rágva, de a kódok sokat elárulnak!

A több MSGEQ7 ic gyári frekvenciáit, úgy tolják el, hogy megváltoztatják a működésükhöz szükséges órajelet! Erről pontos leírás nincs, csak utalás az adatlapon.
A hozzászólás módosítva: Márc 3, 2021
(#) dB_Thunder válasza dB_Thunder hozzászólására (») Márc 3, 2021 /
 
Egy olasz produkció: 7 sáv, dot és bar kijelzés, igényes kivitelezés!
A programkód a lap alján!
denislanfrit
(#) dB_Thunder válasza dB_Thunder hozzászólására (») Márc 3, 2021 /
 
Ezt a kódot nem tudom már honnan kukáztam! Igazából nem is spektrum analizátor csak egy színes kivezérlés jelző!!
VU_meter_multicolor_code:
  1. //************
  2. //Sound Level to light show sketch for the
  3. //autogain microphone Amplifier from Adafruit on pin AO
  4. //plus neopixel led functions (pin 6) mapped on to different sound levels to give music to light effects
  5. //
  6. //*************
  7.  
  8. //lines below set variables for neopixels
  9.  
  10. #include <Adafruit_NeoPixel.h>
  11.  
  12. #define NUMBER_PIXEL 12
  13. #define LEDPIN    6
  14.  
  15. Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMBER_PIXEL, LEDPIN, NEO_GRB + NEO_KHZ800);
  16.  
  17. int lng = 100;//long delay
  18. int sht = 50;//short delay
  19.  
  20. //lines below are for the microphone sampling from Adafruit autogain mic
  21.  
  22. const int sampleWindow = 50; // Sample window width in mS (50 mS = 20Hz)
  23. unsigned int sample;
  24.  
  25. void setup()
  26. {
  27.   strip.begin();//initialises neopixels
  28.   strip.setBrightness(255);// set brightness from 0 to max is 255
  29.   strip.show();//clears any previous data in the strip
  30.   Serial.begin(9600);//set up for checking mic is working
  31. }
  32.  
  33.  
  34. void loop()
  35. {
  36.   //open void loop
  37.   //first run the sound sampling
  38.   unsigned long startMillis = millis(); // Start of sample window
  39.   unsigned int peakToPeak = 0;   // peak-to-peak level
  40.  
  41.   unsigned int signalMax = 0;
  42.   unsigned int signalMin = 1024;
  43.  
  44.   // collect data for 50 mS
  45.   while (millis() - startMillis < sampleWindow)
  46.   {
  47.     //open while loop
  48.     sample = analogRead(0);
  49.     if (sample < 1024)  // toss out spurious readings
  50.     {
  51.       //open 1st if loop in while
  52.       if (sample > signalMax)
  53.       {
  54.         //open 2nd if
  55.         signalMax = sample;  // save just the max levels
  56.       }//close 2nd if
  57.       else if (sample < signalMin)
  58.       {
  59.         //open 3rd if
  60.         signalMin = sample;  // save just the min levels
  61.       }//close 3rd if
  62.     }//close 1st if
  63.   }//close while loop
  64.   peakToPeak = signalMax - signalMin;  // max - min = peak-peak amplitude
  65.   double volts = (peakToPeak * 3.3) / 1024;  // convert to volts
  66.  
  67. //section below maps the signal from the microphone on to 12 options for LED effects
  68.  
  69.   int sound = (volts * 10);
  70.  
  71.   int soundLevel = map(sound, 1, 10, 0, 11);
  72.   Serial.print("The volt level is  ");
  73.   Serial.println(volts);//for debugging
  74.  
  75. //next section is a series of 12 (0-11) 'if' statements which trigger different patterns.
  76. //it is a combination of a traditional VU style meter fill of the strip
  77. // combined with randomised animated patterns to keep it interesting
  78.   if (soundLevel == 0)
  79.   {
  80.     //open if 0. When there is silence a rainbow pattern runs
  81.  
  82.     rainbowCycle(3);//from the neopixel library
  83.  
  84.   }//close if 0 statement
  85.  
  86.  
  87.   if (soundLevel == 1)
  88.   {
  89.     //open level 1 if statement which contains 4 randomised options
  90.  
  91.     int level1Color = random(1, 4);//choose random number 1 - 4
  92.  
  93.     if (level1Color == 1) //if random no 1 chosen light up pixels 1 and 2 red:
  94.     {
  95.  
  96.       strip.setPixelColor(0, 255, 0, 0); // this turns on pixel 1 100% red (range runs 0 - 255) and leaves green and blue off
  97.       strip.setPixelColor(1, 255, 0, 0); //  - you get the idea
  98.       strip.setPixelColor(2, 0, 0, 0);  
  99.       strip.setPixelColor(3, 0, 0, 0);  
  100.       strip.setPixelColor(4, 0, 0, 0);  
  101.       strip.setPixelColor(5, 0, 0, 0);  
  102.       strip.setPixelColor(6, 0, 0, 0);  
  103.       strip.setPixelColor(7, 0, 0, 0);  
  104.       strip.setPixelColor(8, 0, 0, 0);  
  105.       strip.setPixelColor(9, 0, 0, 0);  
  106.       strip.setPixelColor(10, 0, 0, 0);  
  107.       strip.setPixelColor(11, 0, 0, 0);  
  108.       strip.show();
  109.       delay(lng);
  110.     }//close red random no. 1
  111.  
  112.     else if (level1Color == 2) //if random no 2 choses show green
  113.     {
  114.       strip.setPixelColor(0, 0, 255, 0);  
  115.       strip.setPixelColor(1, 0, 255, 0);  
  116.       strip.setPixelColor(2, 0, 0, 0);  
  117.       strip.setPixelColor(3, 0, 0, 0);  
  118.       strip.setPixelColor(4, 0, 0, 0);  
  119.       strip.setPixelColor(5, 0, 0, 0);  
  120.       strip.setPixelColor(6, 0, 0, 0);  
  121.       strip.setPixelColor(7, 0, 0, 0);  
  122.       strip.setPixelColor(8, 0, 0, 0);  
  123.       strip.setPixelColor(9, 0, 0, 0);  
  124.       strip.setPixelColor(10, 0, 0, 0);  
  125.       strip.setPixelColor(11, 0, 0, 0);  
  126.       strip.show();
  127.       delay(lng);
  128.     }//close random no. 2 green
  129.  
  130.     else if (level1Color == 3) //run blue
  131.     {
  132.  
  133.       strip.setPixelColor(0, 0, 0, 255);  
  134.       strip.setPixelColor(1, 0, 0, 255);  
  135.       strip.setPixelColor(2, 0, 0, 0);  
  136.       strip.setPixelColor(3, 0, 0, 0);  
  137.       strip.setPixelColor(4, 0, 0, 0);  
  138.       strip.setPixelColor(5, 0, 0, 0);  
  139.       strip.setPixelColor(6, 0, 0, 0);  
  140.       strip.setPixelColor(7, 0, 0, 0);  
  141.       strip.setPixelColor(8, 0, 0, 0);  
  142.       strip.setPixelColor(9, 0, 0, 0);  
  143.       strip.setPixelColor(10, 0, 0, 0);  
  144.       strip.setPixelColor(11, 0, 0, 0);  
  145.       strip.show();
  146.       delay(lng);
  147.     }//close blue
  148.  
  149.     else if (level1Color == 4) //run yellow
  150.     {
  151.  
  152.       strip.setPixelColor(0, 255, 255, 0);  
  153.       strip.setPixelColor(1, 255, 255, 0);  
  154.       strip.setPixelColor(2, 0, 0, 0);  
  155.       strip.setPixelColor(3, 0, 0, 0);  
  156.       strip.setPixelColor(4, 0, 0, 0);  
  157.       strip.setPixelColor(5, 0, 0, 0);  
  158.       strip.setPixelColor(6, 0, 0, 0);  
  159.       strip.setPixelColor(7, 0, 0, 0);  
  160.       strip.setPixelColor(8, 0, 0, 0);  
  161.       strip.setPixelColor(9, 0, 0, 0);  
  162.       strip.setPixelColor(10, 0, 0, 0);  
  163.       strip.setPixelColor(11, 0, 0, 0);  
  164.       strip.show();
  165.       delay(lng);
  166.     }//close yellow
  167.  
  168.  
  169.  
  170.   }//end of if sound level 1 options
  171.  
  172.  
  173.   if (soundLevel == 2)
  174.   {
  175.     //open level 2
  176.  
  177.     int level2Color = random(1, 5);//choose one of 5 options if sound level 2
  178.  
  179.     if (level2Color == 1) //run red mix
  180.     {
  181.  
  182.       strip.setPixelColor(0, 255, 0, 0);  
  183.       strip.setPixelColor(1, 0, 0, 255);  
  184.       strip.setPixelColor(2, 255, 0, 0);  
  185.       strip.setPixelColor(3, 0, 0, 0);  
  186.       strip.setPixelColor(4, 0, 0, 0);  
  187.       strip.setPixelColor(5, 0, 0, 0);  
  188.       strip.setPixelColor(6, 0, 0, 0);  
  189.       strip.setPixelColor(7, 0, 0, 0);  
  190.       strip.setPixelColor(8, 0, 0, 0);  
  191.       strip.setPixelColor(9, 0, 0, 0);  
  192.       strip.setPixelColor(10, 0, 0, 0);  
  193.       strip.setPixelColor(11, 0, 0, 0);  
  194.       strip.show();
  195.       delay(lng);
  196.     }//close option 1 red
  197.  
  198.     else if (level2Color == 2) //run green mix
  199.     {
  200.       //open option 2
  201.  
  202.       strip.setPixelColor(0, 0, 206, 209);  
  203.       strip.setPixelColor(1, 0, 206, 209);  
  204.       strip.setPixelColor(2, 0, 206, 209);  
  205.       strip.setPixelColor(3, 0, 0, 0);  
  206.       strip.setPixelColor(4, 0, 0, 0);  
  207.       strip.setPixelColor(5, 0, 0, 0);  
  208.       strip.setPixelColor(6, 0, 0, 0);  
  209.       strip.setPixelColor(7, 0, 0, 0);  
  210.       strip.setPixelColor(8, 0, 0, 0);  
  211.       strip.setPixelColor(9, 0, 0, 0);  
  212.       strip.setPixelColor(10, 0, 0, 0);  
  213.       strip.setPixelColor(11, 0, 0, 0);  
  214.       strip.show();
  215.       delay(lng);
  216.     }//close green
  217.  
  218.     else if (level2Color == 3) //run blue mix
  219.     {
  220.       //open option 3
  221.  
  222.       strip.setPixelColor(0, 0, 0, 255);  
  223.       strip.setPixelColor(1, 255, 0, 0);  
  224.       strip.setPixelColor(2, 0, 0, 255);  
  225.       strip.setPixelColor(3, 0, 0, 0);  
  226.       strip.setPixelColor(4, 0, 0, 0);  
  227.       strip.setPixelColor(5, 0, 0, 0);  
  228.       strip.setPixelColor(6, 0, 0, 0);  
  229.       strip.setPixelColor(7, 0, 0, 0);  
  230.       strip.setPixelColor(8, 0, 0, 0);  
  231.       strip.setPixelColor(9, 0, 0, 0);  
  232.       strip.setPixelColor(10, 0, 0, 0);  
  233.       strip.setPixelColor(11, 0, 0, 0);  
  234.       strip.show();
  235.       delay(lng);
  236.     }//close option 3 blue
  237.  
  238.     else if (level2Color == 4) //run yellow
  239.     {
  240.       //open option 4
  241.  
  242.       strip.setPixelColor(0, 255, 255, 0);  
  243.       strip.setPixelColor(1, 255, 255, 0);  
  244.       strip.setPixelColor(2, 255, 255, 0);  
  245.       strip.setPixelColor(3, 0, 0, 0);  
  246.       strip.setPixelColor(4, 0, 0, 0);  
  247.       strip.setPixelColor(5, 0, 0, 0);  
  248.       strip.setPixelColor(6, 0, 0, 0);  
  249.       strip.setPixelColor(7, 0, 0, 0);  
  250.       strip.setPixelColor(8, 0, 0, 0);  
  251.       strip.setPixelColor(9, 0, 0, 0);  
  252.       strip.setPixelColor(10, 0, 0, 0);  
  253.       strip.setPixelColor(11, 0, 0, 0);  
  254.       strip.show();
  255.       delay(lng);
  256.     }//close yellow
  257.  
  258.     else if (level2Color == 5)//for a bit of variation 1 in 5 of level 2 will show a pattern across whole strip:
  259.     {
  260.       //open if 5
  261.       strip.setPixelColor(0, 200, 75, 109);  
  262.       strip.setPixelColor(1, 252, 203, 198);  
  263.       strip.setPixelColor(2, 255, 216, 209);  
  264.       strip.setPixelColor(3, 253, 215, 130);  
  265.       strip.setPixelColor(4, 181, 198, 130);  
  266.       strip.setPixelColor(5, 141, 189, 193);  
  267.       strip.setPixelColor(6, 177, 217, 242);  
  268.       strip.setPixelColor(7, 100, 165, 187);  
  269.       strip.setPixelColor(8, 133, 105, 128);  
  270.       strip.setPixelColor(9, 140, 166, 95);  
  271.       strip.setPixelColor(10, 198, 44, 58);  
  272.       strip.setPixelColor(11, 149, 69, 103);  
  273.  
  274.  
  275.       strip.show();
  276.       delay(lng);
  277.  
  278.       strip.setPixelColor(1, 200, 75, 109);  
  279.       strip.setPixelColor(2, 252, 203, 198);  
  280.       strip.setPixelColor(3, 255, 216, 209);  
  281.       strip.setPixelColor(4, 253, 215, 130);  
  282.       strip.setPixelColor(5, 181, 198, 130);  
  283.       strip.setPixelColor(6, 141, 189, 193);  
  284.       strip.setPixelColor(7, 177, 217, 242);  
  285.       strip.setPixelColor(8, 100, 165, 187);  
  286.       strip.setPixelColor(9, 133, 105, 128);  
  287.       strip.setPixelColor(10, 140, 166, 95);  
  288.       strip.setPixelColor(11, 198, 44, 58);  
  289.       strip.setPixelColor(0, 149, 69, 103);  
  290.  
  291.       strip.show();
  292.       delay(lng);
  293.  
  294.     }//close of option 5
  295.   }//close level 2
  296.  
  297.   if (soundLevel == 3)
  298.   {
  299.     //open if sound level 3
  300.     int level3Color = random(1, 5);
  301.  
  302.     if (level3Color == 1) //run red
  303.     {
  304.       //open option 1
  305.  
  306.       strip.setPixelColor(0, 255, 0, 0);  
  307.       strip.setPixelColor(1, 0, 255, 0);  
  308.       strip.setPixelColor(2, 255, 0, 0);  
  309.       strip.setPixelColor(3, 0, 255, 0);  
  310.       strip.setPixelColor(4, 0, 0, 0);  
  311.       strip.setPixelColor(5, 0, 0, 0);  
  312.       strip.setPixelColor(6, 0, 0, 0);  
  313.       strip.setPixelColor(7, 0, 0, 0);  
  314.       strip.setPixelColor(8, 0, 0, 0);  
  315.       strip.setPixelColor(9, 0, 0, 0);  
  316.       strip.setPixelColor(10, 0, 0, 0);  
  317.       strip.setPixelColor(11, 0, 0, 0);  
  318.       strip.show();
  319.       delay(lng);
  320.     }//close option 1 red
  321.  
  322.     else if (level3Color == 2) //run green
  323.     {
  324.       //open option 2
  325.  
  326.       strip.setPixelColor(0, 245, 116, 97);  
  327.       strip.setPixelColor(1, 169, 221, 20);  
  328.       strip.setPixelColor(2, 245, 116, 97);  
  329.       strip.setPixelColor(3, 169, 221, 20);  
  330.       strip.setPixelColor(4, 0, 0, 0);  
  331.       strip.setPixelColor(5, 0, 0, 0);  
  332.       strip.setPixelColor(6, 0, 0, 0);  
  333.       strip.setPixelColor(7, 0, 0, 0);  
  334.       strip.setPixelColor(8, 0, 0, 0);  
  335.       strip.setPixelColor(9, 0, 0, 0);  
  336.       strip.setPixelColor(10, 0, 0, 0);  
  337.       strip.setPixelColor(11, 0, 0, 0);  
  338.       strip.show();
  339.       delay(lng);
  340.     }//close option 2green
  341.  
  342.     else if (level3Color == 3) //run blue
  343.     {
  344.       //open option 3
  345.  
  346.       strip.setPixelColor(0, 169, 221, 199);  
  347.       strip.setPixelColor(1, 245, 116, 97);  
  348.       strip.setPixelColor(2, 169, 221, 199);  
  349.       strip.setPixelColor(3,  245, 116, 97);  
  350.       strip.setPixelColor(4, 0, 0, 0);  
  351.       strip.setPixelColor(5, 0, 0, 0);  
  352.       strip.setPixelColor(6, 0, 0, 0);  
  353.       strip.setPixelColor(7, 0, 0, 0);  
  354.       strip.setPixelColor(8, 0, 0, 0);  
  355.       strip.setPixelColor(9, 0, 0, 0);  
  356.       strip.setPixelColor(10, 0, 0, 0);  
  357.       strip.setPixelColor(11, 0, 0, 0);  
  358.       strip.show();
  359.       delay(lng);
  360.     }//close option 3 blue
  361.  
  362.     else if (level3Color == 4) //run yellow
  363.     {
  364.       //open option 4
  365.  
  366.       strip.setPixelColor(0, 255, 255, 0);  
  367.       strip.setPixelColor(1, 255, 255, 0);  
  368.       strip.setPixelColor(2, 255, 255, 0);  
  369.       strip.setPixelColor(3, 255, 255, 0);  
  370.       strip.setPixelColor(4, 0, 0, 0);  
  371.       strip.setPixelColor(5, 0, 0, 0);  
  372.       strip.setPixelColor(6, 0, 0, 0);  
  373.       strip.setPixelColor(7, 0, 0, 0);  
  374.       strip.setPixelColor(8, 0, 0, 0);  
  375.       strip.setPixelColor(9, 0, 0, 0);  
  376.       strip.setPixelColor(10, 0, 0, 0);  
  377.       strip.setPixelColor(11, 0, 0, 0);  
  378.       strip.show();
  379.       delay(lng);
  380.     }//close option 4 yellow
  381.  
  382.     else if (level3Color == 5)
  383.     {
  384.       //open option 5
  385.       strip.setPixelColor(0, 255, 255, 255);  
  386.       strip.setPixelColor(1, 255, 105, 180);  
  387.       strip.setPixelColor(2, 255, 255, 255);  
  388.       strip.setPixelColor(3, 255, 105, 180);  
  389.       strip.setPixelColor(4, 255, 255, 255);  
  390.       strip.setPixelColor(5, 255, 105, 180);  
  391.       strip.setPixelColor(6, 255, 255, 255);  
  392.       strip.setPixelColor(7, 255, 105, 180);  
  393.       strip.setPixelColor(8, 255, 255, 255);  
  394.       strip.setPixelColor(9, 255, 105, 180);  
  395.       strip.setPixelColor(10, 255, 255, 255);  
  396.       strip.setPixelColor(11, 255, 105, 180);  
  397.       strip.show();
  398.       delay(sht);
  399.     }//close of option 5
  400.   }//close level 3
  401.  
  402.  
  403.   if (soundLevel == 4)
  404.   {
  405.     //open if sound level 4
  406.     int level4Color = random(1, 5);
  407.  
  408.     if (level4Color == 1) //run red
  409.     {
  410.       //open option 1
  411.  
  412.       strip.setPixelColor(0, 255, 0, 0);  
  413.       strip.setPixelColor(1, 0, 0, 255);  
  414.       strip.setPixelColor(2, 255, 0, 0);  
  415.       strip.setPixelColor(3, 0, 0, 255);  
  416.       strip.setPixelColor(4, 255, 0, 0);  
  417.       strip.setPixelColor(5, 0, 0, 0);  
  418.       strip.setPixelColor(6, 0, 0, 0);  
  419.       strip.setPixelColor(7, 0, 0, 0);  
  420.       strip.setPixelColor(8, 0, 0, 0);  
  421.       strip.setPixelColor(9, 0, 0, 0);  
  422.       strip.setPixelColor(10, 0, 0, 0);  
  423.       strip.setPixelColor(11, 0, 0, 0);  
  424.       strip.show();
  425.       delay(lng);
  426.     }//close red
  427.  
  428.     else if (level4Color == 2) //run green
  429.     {
  430.       //open option 2
  431.  
  432.       strip.setPixelColor(0, 0, 255, 0);  
  433.       strip.setPixelColor(1, 0, 255, 0);  
  434.       strip.setPixelColor(2, 0, 255, 0);  
  435.       strip.setPixelColor(3, 0, 255, 0);  
  436.       strip.setPixelColor(4, 0, 255, 0);  
  437.       strip.setPixelColor(5, 0, 0, 0);  
  438.       strip.setPixelColor(6, 0, 0, 0);  
  439.       strip.setPixelColor(7, 0, 0, 0);  
  440.       strip.setPixelColor(8, 0, 0, 0);  
  441.       strip.setPixelColor(9, 0, 0, 0);  
  442.       strip.setPixelColor(10, 0, 0, 0);  
  443.       strip.setPixelColor(11, 0, 0, 0);  
  444.       strip.show();
  445.       delay(lng);
  446.     }//close green
  447.  
  448.     else if (level4Color == 3) //run blue
  449.     {
  450.       //open option 3
  451.  
  452.       strip.setPixelColor(0, 0, 0, 255);  
  453.       strip.setPixelColor(1, 0, 0, 255);  
  454.       strip.setPixelColor(2, 0, 0, 255);  
  455.       strip.setPixelColor(3, 0, 0, 255);  
  456.       strip.setPixelColor(4, 0, 0, 255);  
  457.       strip.setPixelColor(5, 0, 0, 0);  
  458.       strip.setPixelColor(6, 0, 0, 0);  
  459.       strip.setPixelColor(7, 0, 0, 0);  
  460.       strip.setPixelColor(8, 0, 0, 0);  
  461.       strip.setPixelColor(9, 0, 0, 0);  
  462.       strip.setPixelColor(10, 0, 0, 0);  
  463.       strip.setPixelColor(11, 0, 0, 0);  
  464.       strip.show();
  465.       delay(lng);
  466.     }//close blue
  467.  
  468.     else if (level4Color == 4) //run yellow
  469.     {
  470.       //open option 4
  471.  
  472.       strip.setPixelColor(0, 255, 255, 0);  
  473.       strip.setPixelColor(1, 255, 255, 0);  
  474.       strip.setPixelColor(2, 255, 255, 0);  
  475.       strip.setPixelColor(3, 255, 255, 0);  
  476.       strip.setPixelColor(4, 255, 255, 0);  
  477.       strip.setPixelColor(5, 0, 0, 0);  
  478.       strip.setPixelColor(6, 0, 0, 0);  
  479.       strip.setPixelColor(7, 0, 0, 0);  
  480.       strip.setPixelColor(8, 0, 0, 0);  
  481.       strip.setPixelColor(9, 0, 0, 0);  
  482.       strip.setPixelColor(10, 0, 0, 0);  
  483.       strip.setPixelColor(11, 0, 0, 0);  
  484.       strip.show();
  485.       delay(lng);
  486.     }//close yellow
  487.  
  488.     else if (level4Color == 5)
  489.     {
  490.       ////open option 5
  491.       strip.setPixelColor(0, 255, 01, 165);  
  492.       strip.setPixelColor(1, 255, 187, 218);  
  493.       strip.setPixelColor(2, 228, 194, 191);  
  494.       strip.setPixelColor(3, 153, 87, 205);  
  495.       strip.setPixelColor(4, 176, 284, 218);  
  496.       strip.setPixelColor(5, 67, 142, 200);  
  497.       strip.setPixelColor(6, 107, 167, 214);  
  498.       strip.setPixelColor(7, 168, 204, 232);  
  499.       strip.setPixelColor(8, 59, 198, 182);  
  500.       strip.setPixelColor(9, 100, 212, 199);  
  501.       strip.setPixelColor(10, 164, 231, 223);  
  502.       strip.setPixelColor(11, 176, 124, 218);  
  503.       strip.show();
  504.       delay(lng);
  505.     }//close option 5
  506.  
  507.   }//close if sound level 4
  508.  
  509.   else if (soundLevel == 5)
  510.   {
  511.     //open if sound level 5
  512.  
  513.  
  514.     int level5Color = random(1, 6);
  515.  
  516.     if (level5Color == 1) //run red
  517.     {
  518.       //open option 1
  519.  
  520.       strip.setPixelColor(0, 255, 0, 0);  
  521.       strip.setPixelColor(1, 255, 255, 255);  
  522.       strip.setPixelColor(2, 0, 0, 255);  
  523.       strip.setPixelColor(3, 255, 0, 0);  
  524.       strip.setPixelColor(4, 255, 255, 255);  
  525.       strip.setPixelColor(5, 0, 0, 255);  
  526.       strip.setPixelColor(6, 0, 0, 0);  
  527.       strip.setPixelColor(7, 0, 0, 0);  
  528.       strip.setPixelColor(8, 0, 0, 0);  
  529.       strip.setPixelColor(9, 0, 0, 0);  
  530.       strip.setPixelColor(10, 0, 0, 0);  
  531.       strip.setPixelColor(11, 0, 0, 0);  
  532.       strip.show();
  533.       delay(lng);
  534.     }//close option 1 red
  535.  
  536.     else if (level5Color == 2) //run green
  537.     {
  538.       //open option 2
  539.  
  540.       strip.setPixelColor(0, 0, 255, 0);  
  541.       strip.setPixelColor(1, 0, 255, 0);  
  542.       strip.setPixelColor(2, 0, 255, 0);  
  543.       strip.setPixelColor(3, 0, 255, 0);  
  544.       strip.setPixelColor(4, 0, 255, 0);  
  545.       strip.setPixelColor(5, 0, 255, 0);  
  546.       strip.setPixelColor(6, 0, 0, 0);  
  547.       strip.setPixelColor(7, 0, 0, 0);  
  548.       strip.setPixelColor(8, 0, 0, 0);  
  549.       strip.setPixelColor(9, 0, 0, 0);  
  550.       strip.setPixelColor(10, 0, 0, 0);  
  551.       strip.setPixelColor(11, 0, 0, 0);  
  552.       strip.show();
  553.       delay(lng);
  554.     }//close option 2 green
  555.  
  556.     else if (level5Color == 3) //run blue
  557.     {
  558.       //open option 3
  559.  
  560.       strip.setPixelColor(0, 0, 0, 255);  
  561.       strip.setPixelColor(1, 0, 0, 255);  
  562.       strip.setPixelColor(2, 0, 0, 255);  
  563.       strip.setPixelColor(3, 0, 0, 255);  
  564.       strip.setPixelColor(4, 0, 0, 255);  
  565.       strip.setPixelColor(5, 0, 0, 255);  
  566.       strip.setPixelColor(6, 0, 0, 0);  
  567.       strip.setPixelColor(7, 0, 0, 0);  
  568.       strip.setPixelColor(8, 0, 0, 0);  
  569.       strip.setPixelColor(9, 0, 0, 0);  
  570.       strip.setPixelColor(10, 0, 0, 0);  
  571.       strip.setPixelColor(11, 0, 0, 0);  
  572.       strip.show();
  573.       delay(lng);
  574.     }//close option 3 blue
  575.  
  576.     else if (level5Color == 4) //run yellow
  577.     {
  578.       //open option 4
  579.  
  580.       strip.setPixelColor(0, 255, 255, 0);  
  581.       strip.setPixelColor(1, 255, 255, 0);  
  582.       strip.setPixelColor(2, 255, 255, 0);  
  583.       strip.setPixelColor(3, 255, 255, 0);  
  584.       strip.setPixelColor(4, 255, 255, 0);  
  585.       strip.setPixelColor(5, 255, 255, 0);  
  586.       strip.setPixelColor(6, 0, 0, 0);  
  587.       strip.setPixelColor(7, 0, 0, 0);  
  588.       strip.setPixelColor(8, 0, 0, 0);  
  589.       strip.setPixelColor(9, 0, 0, 0);  
  590.       strip.setPixelColor(10, 0, 0, 0);  
  591.       strip.setPixelColor(11, 0, 0, 0);  
  592.       strip.show();
  593.       delay(lng);
  594.     }//close yellow
  595.  
  596.     else if (level5Color == 5)
  597.     {
  598.       //open option 5
  599.  
  600.       strip.setPixelColor(0, 255, 0, 0);  
  601.       strip.setPixelColor(1, 0, 255, 0);  
  602.       strip.setPixelColor(2, 0, 0, 255);  
  603.       strip.setPixelColor(3, 255, 0, 0);  
  604.       strip.setPixelColor(4, 0, 255, 0);  
  605.       strip.setPixelColor(5, 0, 0, 255);      
  606. strip.setPixelColor(6, 0, 0, 255);  
  607.       strip.setPixelColor(6, 255, 0, 0);  
  608.       strip.setPixelColor(7, 0, 255, 0);  
  609.       strip.setPixelColor(8, 0, 0, 255);  
  610.       strip.setPixelColor(9, 255, 0, 0);  
  611.       strip.setPixelColor(10, 0, 255, 0);  
  612.       strip.setPixelColor(11, 0, 0, 255);  
  613.       strip.show();
  614.       delay(lng);
  615.     }//close option 5
  616.  
  617.     else if (level5Color == 6)
  618.     {
  619.       //open option 6
  620.  
  621.       colorWipe(strip.Color(255, 0, 255), 50); // magenta
  622.       colorWipe(strip.Color(0, 255, 0), 50); // green
  623.       strip.show();
  624.     }//close option 6
  625.   }//close if sound level 5
  626.  
  627.  
  628.   else if (soundLevel == 6)
  629.   {
  630.     //open if soundlevel 6
  631.  
  632.     int level6Color = random(1, 6);
  633.  
  634.     if (level6Color == 1) //run red
  635.     {
  636.       //open option 1
  637.  
  638.       strip.setPixelColor(0, 255, 0, 0);  
  639.       strip.setPixelColor(1, 255, 255, 255);  
  640.       strip.setPixelColor(2, 0, 0, 255);  
  641.       strip.setPixelColor(3, 255, 0, 0);  
  642.       strip.setPixelColor(4, 255, 255, 255);  
  643.       strip.setPixelColor(5, 0, 0, 255);  
  644.       strip.setPixelColor(6, 255, 0, 0);  
  645.       strip.setPixelColor(7, 0, 0, 0);  
  646.       strip.setPixelColor(8, 0, 0, 0);  
  647.       strip.setPixelColor(9, 0, 0, 0);  
  648.       strip.setPixelColor(10, 0, 0, 0);  
  649.       strip.setPixelColor(11, 0, 0, 0);  
  650.       strip.show();
  651.       delay(lng);
  652.     }//close option 1red
  653.  
  654.     else if (level6Color == 2) //run green
  655.     {
  656.       //open option 2
  657.  
  658.       strip.setPixelColor(0, 0, 255, 0);  
  659.       strip.setPixelColor(1, 0, 255, 0);  
  660.       strip.setPixelColor(2, 0, 255, 0);  
  661.       strip.setPixelColor(3, 0, 255, 0);  
  662.       strip.setPixelColor(4, 0, 255, 0);  
  663.       strip.setPixelColor(5, 0, 255, 0);  
  664.       strip.setPixelColor(6, 0, 255, 0);  
  665.       strip.setPixelColor(7, 0, 0, 0);  
  666.       strip.setPixelColor(8, 0, 0, 0);  
  667.       strip.setPixelColor(9, 0, 0, 0);  
  668.       strip.setPixelColor(10, 0, 0, 0);  
  669.       strip.setPixelColor(11, 0, 0, 0);  
  670.       strip.show();
  671.       delay(lng);
  672.     }//close option 2 green
  673.  
  674.     else if (level6Color == 3) //run blue
  675.     {
  676.       //open option 3
  677.  
  678.       strip.setPixelColor(0, 0, 0, 255);  
  679.       strip.setPixelColor(1, 0, 0, 255);  
  680.       strip.setPixelColor(2, 0, 0, 255);  
  681.       strip.setPixelColor(3, 0, 0, 255);  
  682.       strip.setPixelColor(4, 0, 0, 255);  
  683.       strip.setPixelColor(5, 0, 0, 255);  
  684.       strip.setPixelColor(6, 0, 0, 255);  
  685.       strip.setPixelColor(7, 0, 0, 0);  
  686.       strip.setPixelColor(8, 0, 0, 0);  
  687.       strip.setPixelColor(9, 0, 0, 0);  
  688.       strip.setPixelColor(10, 0, 0, 0);  
  689.       strip.setPixelColor(11, 0, 0, 0);  
  690.       strip.show();
  691.       delay(lng);
  692.     }//close option 3 blue
  693.  
  694.     else if (level6Color == 4) //run yellow
  695.     {
  696.       //open option 4
  697.  
  698.       strip.setPixelColor(0, 148, 0, 211);  
  699.       strip.setPixelColor(1, 75, 0, 130);  
  700.       strip.setPixelColor(2, 0, 0, 255);  
  701.       strip.setPixelColor(3, 0, 255, 0);  
  702.       strip.setPixelColor(4, 255, 255, 0);  
  703.       strip.setPixelColor(5, 255, 127, 0);  
  704.       strip.setPixelColor(6, 255, 0, 0);  
  705.       strip.setPixelColor(7, 0, 0, 0);  
  706.       strip.setPixelColor(8, 0, 0, 0);  
  707.       strip.setPixelColor(9, 0, 0, 0);  
  708.       strip.setPixelColor(10, 0, 0, 0);  
  709.       strip.setPixelColor(11, 0, 0, 0);  
  710.       strip.show();
  711.       delay(sht);
  712.     }//close yellow
  713.  
  714.     else if (level6Color == 5)
  715.     {
  716.       //open option 5
  717.       colorWipe(strip.Color(0, 0, 255), 50); // Blue
  718.       colorWipe(strip.Color(255, 255, 0), 50); // yellow
  719.       strip.show();
  720.     }//close option 5
  721.  
  722.     else if (level6Color == 6)
  723.     {
  724.       //open option6
  725.  
  726.       theaterChase(strip.Color(200, 0, 0), 50); // Red
  727.       strip.show();
  728.       delay(lng);
  729.     }//close option 6
  730.   }//close if sound level 6
  731.  
  732.   else if (soundLevel == 7)
  733.   {
  734.     //open if sound level 7
  735.     int level7Color = random(1, 7);
  736.  
  737.     if (level7Color == 1) //run red
  738.     {
  739.       //open option 1
  740.  
  741.       strip.setPixelColor(0, 255, 0, 0);  
  742.       strip.setPixelColor(1, 255, 0, 0);  
  743.       strip.setPixelColor(2, 255, 0, 0);  
  744.       strip.setPixelColor(3, 255, 0, 0);  
  745.       strip.setPixelColor(4, 255, 0, 0);  
  746.       strip.setPixelColor(5, 255, 0, 0);  
  747.       strip.setPixelColor(6, 255, 0, 0);  
  748.       strip.setPixelColor(7, 255, 0, 0);  
  749.       strip.setPixelColor(8, 0, 0, 0);  
  750.       strip.setPixelColor(9, 0, 0, 0);  
  751.       strip.setPixelColor(10, 0, 0, 0);  
  752.       strip.setPixelColor(11, 0, 0, 0);  
  753.       strip.show();
  754.       delay(lng);
  755.     }//close option 1 red
  756.  
  757.     else if (level7Color == 2) //run green
  758.     {
  759.       //open option 2
  760.  
  761.       strip.setPixelColor(0, 0, 255, 0);  
  762.       strip.setPixelColor(1, 0, 255, 0);  
  763.       strip.setPixelColor(2, 0, 255, 0);  
  764.       strip.setPixelColor(3, 0, 255, 0);  
  765.       strip.setPixelColor(4, 0, 255, 0);  
  766.       strip.setPixelColor(5, 0, 255, 0);  
  767.       strip.setPixelColor(6, 0, 255, 0);  
  768.       strip.setPixelColor(7, 0, 255, 0);  
  769.       strip.setPixelColor(8, 0, 0, 0);  
  770.       strip.setPixelColor(9, 0, 0, 0);  
  771.       strip.setPixelColor(10, 0, 0, 0);  
  772.       strip.setPixelColor(11, 0, 0, 0);  
  773.       strip.show();
  774.       delay(lng);
  775.     }//close option 2 green
  776.  
  777.     else if (level7Color == 3) //run blue
  778.     {
  779.       //open option 3
  780.  
  781.       strip.setPixelColor(0, 0, 0, 255);  
  782.       strip.setPixelColor(1, 0, 0, 255);  
  783.       strip.setPixelColor(2, 0, 0, 255);  
  784.       strip.setPixelColor(3, 0, 0, 255);  
  785.       strip.setPixelColor(4, 0, 0, 255);  
  786.       strip.setPixelColor(5, 0, 0, 255);  
  787.       strip.setPixelColor(6, 0, 0, 255);  
  788.       strip.setPixelColor(7, 0, 0, 255);  
  789.       strip.setPixelColor(8, 0, 0, 0);  
  790.       strip.setPixelColor(9, 0, 0, 0);  
  791.       strip.setPixelColor(10, 0, 0, 0);  
  792.       strip.setPixelColor(11, 0, 0, 0);  
  793.       strip.show();
  794.       delay(lng);
  795.     }//close option 3 blue
  796.  
  797.     else if (level7Color == 4) //run yellow
  798.     {
  799.       //open option 4
  800.  
  801.       strip.setPixelColor(0, 255, 255, 0);  
  802.       strip.setPixelColor(1, 255, 255, 0);  
  803.       strip.setPixelColor(2, 255, 255, 0);  
  804.       strip.setPixelColor(3, 255, 255, 0);  
  805.       strip.setPixelColor(4, 255, 255, 0);  
  806.       strip.setPixelColor(5, 255, 255, 0);  
  807.       strip.setPixelColor(6, 255, 255, 0);  
  808.       strip.setPixelColor(7, 255, 255, 0);  
  809.       strip.setPixelColor(8, 0, 0, 0);  
  810.       strip.setPixelColor(9, 0, 0, 0);  
  811.       strip.setPixelColor(10, 0, 0, 0);  
  812.       strip.setPixelColor(11, 0, 0, 0);  
  813.       strip.show();
  814.       delay(lng);
  815.     }//close option 4 yellow
  816.  
  817.     else if (level7Color == 5)
  818.     {
  819.       //open option 5
  820.       colorWipe(strip.Color(255, 20, 147), 50); // pink
  821.       colorWipe(strip.Color(0, 206, 209), 50); // turquoise
  822.       strip.show();
  823.       delay(lng);
  824.     }//close option 5
  825.  
  826.     else if (level7Color == 6)
  827.     {
  828.       //open option 6
  829.  
  830.       theaterChase(strip.Color(255, 20, 100), 50); // Red
  831.       strip.show();
  832.       delay(sht);
  833.     }//close option 6
  834.  
  835.     else if (level7Color == 7)
  836.     {
  837.       //open option 7
  838.       strip.setPixelColor(0, 0, 70, 70);  
  839.       strip.setPixelColor(1, 0, 100, 0);  
  840.       strip.setPixelColor(2, 255, 0, 70);  
  841.       strip.setPixelColor(3, 50, 0, 150);  
  842.       strip.setPixelColor(4, 0, 70, 70);  
  843.       strip.setPixelColor(5, 0, 100, 0);  
  844.       strip.setPixelColor(6, 255, 0, 70);  
  845.       strip.setPixelColor(7, 50, 0, 150);  
  846. strip.setPixelColor(0, 0, 70, 70);  
  847.       strip.setPixelColor(8, 255, 0, 70);  
  848.       strip.setPixelColor(9, 0, 100, 0);  
  849.       strip.setPixelColor(10, 255, 0, 70);  
  850.       strip.setPixelColor(11, 50, 0, 150);  
  851.  
  852.       strip.show();
  853.       delay(sht);
  854.     }//close option 7
  855.   }//close if sound level 7
  856.  
  857.   else if (soundLevel == 8)
  858.   {
  859.     //open if sound level 8
  860.  
  861.     int level8Color = random(1, 8);
  862.  
  863.     if (level8Color == 1) //run red
  864.     {
  865.       //open option 1
  866.       strip.setPixelColor(0, 255, 0, 0);  
  867.       strip.setPixelColor(1, 255, 0, 0);  
  868.       strip.setPixelColor(2, 255, 0, 0);  
  869.       strip.setPixelColor(3, 255, 0, 0);  
  870.       strip.setPixelColor(4, 255, 0, 0);  
  871.       strip.setPixelColor(5, 255, 0, 0);  
  872.       strip.setPixelColor(6, 255, 0, 0);  
  873.       strip.setPixelColor(7, 255, 0, 0);  
  874.       strip.setPixelColor(8, 255, 0, 0);  
  875.       strip.setPixelColor(9, 0, 0, 0);  
  876.       strip.setPixelColor(10, 0, 0, 0);  
  877.       strip.setPixelColor(11, 0, 0, 0);  
  878.       strip.show();
  879.       delay(lng);
  880.     }//close option 1 red
  881.  
  882.     else if (level8Color == 2) //run green/blue
  883.     {
  884.       //open option 2
  885.  
  886.       strip.setPixelColor(0, 0, 255, 0);  
  887.       strip.setPixelColor(1, 0, 0, 255);  
  888.       strip.setPixelColor(2, 0, 255, 0);  
  889.       strip.setPixelColor(3, 0, 0, 255);  
  890.       strip.setPixelColor(4, 0, 255, 0);  
  891.       strip.setPixelColor(5, 0, 0, 255);  
  892.       strip.setPixelColor(6, 0, 255, 0);  
  893.       strip.setPixelColor(7, 0, 0, 255);  
  894.       strip.setPixelColor(8, 0, 255, 0);  
  895.       strip.setPixelColor(9, 0, 0, 0);  
  896.       strip.setPixelColor(10, 0, 0, 0);  
  897.       strip.setPixelColor(11, 0, 0, 0);  
  898.       strip.show();
  899.       delay(lng);
  900.     }//close option 2 green/blue
  901.  
  902.     else if (level8Color == 3) //run turquoise / blue
  903.     {
  904.       //open option 3
  905.  
  906.       strip.setPixelColor(0, 0, 206, 255);  
  907.       strip.setPixelColor(1, 0, 0, 255);  
  908.       strip.setPixelColor(2, 0, 206, 255);  
  909.       strip.setPixelColor(3, 0, 0, 255);  
  910.       strip.setPixelColor(4, 0, 206, 255);  
  911.       strip.setPixelColor(5, 0, 0, 255);  
  912.       strip.setPixelColor(6, 0, 206, 255);  
  913.       strip.setPixelColor(7, 0, 0, 255);  
  914.       strip.setPixelColor(8, 0, 206, 255);  
  915.       strip.setPixelColor(9, 0, 0, 0);  
  916.       strip.setPixelColor(10, 0, 0, 0);  
  917.       strip.setPixelColor(11, 0, 0, 0);  
  918.       strip.show();
  919.       delay(lng);
  920.     }//close option 3 blue
  921.  
  922.     else if (level8Color == 4) //run yellow
  923.     {
  924.       //open option 4
  925.  
  926.       strip.setPixelColor(0, 255, 255, 0);  
  927.       strip.setPixelColor(1, 255, 255, 0);  
  928.       strip.setPixelColor(2, 255, 255, 0);  
  929.       strip.setPixelColor(3, 255, 255, 0);  
  930.       strip.setPixelColor(4, 255, 255, 0);  
  931.       strip.setPixelColor(5, 255, 255, 0);  
  932.       strip.setPixelColor(6, 255, 255, 0);  
  933.       strip.setPixelColor(7, 255, 255, 0);  
  934.       strip.setPixelColor(8, 255, 255, 0);  
  935.       strip.setPixelColor(9, 0, 0, 0);  
  936.       strip.setPixelColor(10, 0, 0, 0);  
  937.       strip.setPixelColor(11, 0, 0, 0);  
  938.       strip.show();
  939.       delay(lng);
  940.     }//close option 4 yellow
  941.  
  942.     else if (level8Color == 5)
  943.     {
  944.       //open option 5
  945.       colorWipe(strip.Color(255, 20, 147), 20); // pink
  946.       colorWipe(strip.Color(0, 206, 209), 20); // turquoise
  947.       strip.show();
  948.     }//close option 5
  949.  
  950.     else if (level8Color == 6)
  951.     {
  952.       //open option 6
  953.  
  954.       theaterChase(strip.Color(0, 206, 209), 50); // Red
  955.       strip.show();
  956.       delay(sht);
  957.     }//close option 6
  958.  
  959.     else if (level8Color == 7)
  960.     {
  961.       //open option 7
  962.       strip.setPixelColor(0, 0, 70, 70);  
  963.       strip.setPixelColor(1, 0, 100, 0);  
  964.       strip.setPixelColor(2, 255, 0, 70);  
  965.       strip.setPixelColor(3, 50, 0, 150);  
  966.       strip.setPixelColor(4, 0, 70, 70);  
  967.       strip.setPixelColor(5, 0, 100, 0);  
  968.       strip.setPixelColor(6, 255, 0, 70);  
  969.       strip.setPixelColor(7, 50, 0, 150);  
  970. strip.setPixelColor(0, 0, 70, 70);  
  971.       strip.setPixelColor(8, 255, 0, 70);  
  972.       strip.setPixelColor(9, 0, 100, 0);  
  973.       strip.setPixelColor(10, 255, 0, 70);  
  974.       strip.setPixelColor(11, 50, 0, 150);  
  975.  
  976.       strip.show();
  977.       delay(lng);
  978.  
  979.       strip.setPixelColor(0, 0, 255, 255);  
  980.       strip.setPixelColor(1, 0, 255, 255);  
  981.       strip.setPixelColor(2, 0, 0, 0);  
  982.       strip.setPixelColor(3, 255, 255, 0);  
  983.       strip.setPixelColor(4, 255, 255, 0);  
  984.       strip.setPixelColor(5, 0, 0, 0);  
  985.       strip.setPixelColor(6, 0, 255, 255);  
  986.       strip.setPixelColor(7, 0, 255, 255);  
  987.       strip.setPixelColor(8, 0, 0, 0);  
  988.       strip.setPixelColor(9, 255, 255, 0);  
  989.       strip.setPixelColor(10, 255, 255, 0);  
  990.       strip.setPixelColor(11, 0, 0, 0);  
  991.       strip.show();
  992.       delay(lng);
  993.  
  994.  
  995.     }//close option 7
  996.  
  997.   }//close if sound level 8
  998.  
  999.   else if (soundLevel == 9)
  1000.   {
  1001.     //open if sound level 9
  1002.  
  1003.     int level9Color = random(1, 8);
  1004.  
  1005.     if (level9Color == 1) //run red
  1006.     {
  1007.       //open option 1
  1008.  
  1009.       strip.setPixelColor(0, 255, 0, 0);  
  1010.       strip.setPixelColor(1, 255, 0, 0);  
  1011.       strip.setPixelColor(2, 255, 0, 0);  
  1012.       strip.setPixelColor(3, 255, 0, 0);  
  1013.       strip.setPixelColor(4, 255, 0, 0);  
  1014.       strip.setPixelColor(5, 255, 0, 0);  
  1015.       strip.setPixelColor(6, 255, 0, 0);  
  1016.       strip.setPixelColor(7, 255, 0, 0);  
  1017.       strip.setPixelColor(8, 255, 0, 0);  
  1018.       strip.setPixelColor(9, 255, 0, 0);  
  1019.       strip.setPixelColor(10, 0, 0, 0);  
  1020.       strip.setPixelColor(11, 0, 0, 0);  
  1021.       strip.show();
  1022.       delay(lng);
  1023.     }//close option 1 red
  1024.  
  1025.     else if (level9Color == 2) //run green
  1026.     {
  1027.       //open option 2
  1028.  
  1029.       strip.setPixelColor(0, 0, 255, 0);  
  1030.       strip.setPixelColor(1, 0, 0, 255);  
  1031.       strip.setPixelColor(2, 0, 255, 0);  
  1032.       strip.setPixelColor(3, 0, 0, 255);  
  1033.       strip.setPixelColor(4, 0, 255, 0);  
  1034.       strip.setPixelColor(5, 0, 0, 255);  
  1035.       strip.setPixelColor(6, 0, 255, 0);  
  1036.       strip.setPixelColor(7, 0, 0, 255);  
  1037.       strip.setPixelColor(8, 0, 255, 0);  
  1038.       strip.setPixelColor(9, 0, 0, 255);  
  1039.       strip.setPixelColor(10, 0, 0, 0);  
  1040.       strip.setPixelColor(11, 0, 0, 0);  
  1041.       strip.show();
  1042.       delay(lng);
  1043.     }//close option 2 green
  1044.  
  1045.     else if (level9Color == 3) //run blue
  1046.     {
  1047.       //open option 3
  1048.       strip.setPixelColor(0, 255, 0, 255);  
  1049.       strip.setPixelColor(1, 0, 0, 255);  
  1050.       strip.setPixelColor(2, 255, 0, 255);  
  1051.       strip.setPixelColor(3, 0, 0, 255);  
  1052.       strip.setPixelColor(4, 255, 0, 255);  
  1053.       strip.setPixelColor(5, 0, 0, 255);  
  1054.       strip.setPixelColor(6, 255, 0, 255);  
  1055.       strip.setPixelColor(7, 0, 0, 255);  
  1056.       strip.setPixelColor(8, 255, 0, 255);  
  1057.       strip.setPixelColor(9, 0, 0, 255);  
  1058.       strip.setPixelColor(10, 0, 0, 0);  
  1059.       strip.setPixelColor(11, 0, 0, 0);  
  1060.       strip.show();
  1061.       delay(lng);
  1062.     }//close option 3blue
  1063.  
  1064.     else if (level9Color == 4) //run yellow
  1065.     {
  1066.       //open option 4
  1067.  
  1068.       strip.setPixelColor(0, 255, 255, 0);  
  1069.       strip.setPixelColor(1, 255, 255, 0);  
  1070.       strip.setPixelColor(2, 255, 255, 0);  
  1071.       strip.setPixelColor(3, 255, 255, 0);  
  1072.       strip.setPixelColor(4, 255, 255, 0);  
  1073.       strip.setPixelColor(5, 255, 255, 0);  
  1074.       strip.setPixelColor(6, 255, 255, 0);  
  1075.       strip.setPixelColor(7, 255, 255, 0);  
  1076.       strip.setPixelColor(8, 255, 255, 0);  
  1077.       strip.setPixelColor(9, 255, 255, 0);  
  1078.       strip.setPixelColor(10, 0, 0, 0);  
  1079.       strip.setPixelColor(11, 0, 0, 0);  
  1080.       strip.show();
  1081.       delay(lng);
  1082.     }//close option 4 yellow
  1083.  
  1084.     else if (level9Color == 5)
  1085.     {
  1086.       //open option 5
  1087.       colorWipe(strip.Color(255, 255, 255), 60); // white
  1088.       colorWipe(strip.Color(0, 206, 209), 20); // turquoise
  1089.       strip.show();
  1090.     }//close option 5
  1091.  
  1092.     else if (level9Color == 6)
  1093.     {
  1094.       //open option 6
  1095.  
  1096.       theaterChase(strip.Color(50, 190, 209), 50); // turquise
  1097.       strip.show();
  1098.       delay(lng);
  1099.     }//close option 6
  1100.  
  1101.     else if (level9Color == 7)
  1102.     {
  1103.       //open option 7
  1104.       strip.setPixelColor(0, 0, 70, 70);  
  1105.       strip.setPixelColor(1, 0, 100, 0);  
  1106.       strip.setPixelColor(2, 255, 0, 70);  
  1107.       strip.setPixelColor(3, 50, 0, 150);  
  1108.       strip.setPixelColor(4, 0, 70, 70);  
  1109.       strip.setPixelColor(5, 0, 100, 0);  
  1110.       strip.setPixelColor(6, 255, 0, 70);  
  1111.       strip.setPixelColor(7, 50, 0, 150);  
  1112.       strip.setPixelColor(8, 255, 0, 70);  
  1113.       strip.setPixelColor(9, 0, 100, 0);  
  1114.       strip.setPixelColor(10, 255, 0, 70);  
  1115.       strip.setPixelColor(11, 50, 0, 150);  
  1116.  
  1117.       strip.show();
  1118.       delay(lng);
  1119.  
  1120.       strip.setPixelColor(0, 0, 255, 255);  
  1121.       strip.setPixelColor(1, 0, 255, 255);  
  1122.       strip.setPixelColor(2, 0, 0, 0);  
  1123.       strip.setPixelColor(3, 255, 255, 0);  
  1124.       strip.setPixelColor(4, 255, 255, 0);  
  1125.       strip.setPixelColor(5, 0, 0, 0);  
  1126.       strip.setPixelColor(6, 0, 255, 255);  
  1127.       strip.setPixelColor(7, 0, 255, 255);  
  1128.       strip.setPixelColor(8, 0, 0, 0);  
  1129.       strip.setPixelColor(9, 255, 255, 0);  
  1130.       strip.setPixelColor(10, 255, 255, 0);  
  1131.       strip.setPixelColor(11, 0, 0, 0);  
  1132.       strip.show();
  1133.       delay(lng);
  1134.  
  1135.       strip.setPixelColor(0, 255, 50, 50);  
  1136.       strip.setPixelColor(1, 0, 255, 0);  
  1137.       strip.setPixelColor(2, 255, 50, 50);  
  1138.       strip.setPixelColor(3, 255, 0, 0);  
  1139.       strip.setPixelColor(4, 255, 50, 50);  
  1140.       strip.setPixelColor(5, 0, 0, 255);  
  1141.       strip.setPixelColor(6, 255, 50, 50);  
  1142.       strip.setPixelColor(7, 0, 255, 0);  
  1143.       strip.setPixelColor(8, 255, 50, 50);  
  1144.       strip.setPixelColor(9, 255, 0, 0);  
  1145.       strip.setPixelColor(10, 255, 50, 50);  
  1146.       strip.setPixelColor(11, 0, 0, 255);  
  1147.       strip.show();
  1148.  
  1149.       delay(lng);
  1150.  
  1151.  
  1152.     }//close option 7
  1153.  
  1154.     else if (level9Color == 8)
  1155.     {
  1156.       //open option 8
  1157.       strip.setPixelColor(0, 255, 255, 255);  
  1158.       strip.setPixelColor(1, 0, 0, 0);  
  1159.       strip.setPixelColor(2, 255, 255, 255);  
  1160.       strip.setPixelColor(3, 0, 0, 0);  
  1161.       strip.setPixelColor(4, 255, 255, 255);  
  1162.       strip.setPixelColor(5, 0, 0, 0);  
  1163.       strip.setPixelColor(6, 255, 255, 255);  
  1164.       strip.setPixelColor(7, 0, 0, 0);  
  1165.       strip.setPixelColor(8, 255, 255, 255);  
  1166.       strip.setPixelColor(9, 0, 0, 0);  
  1167.       strip.setPixelColor(10, 255, 255, 255);  
  1168.       strip.setPixelColor(11, 0, 0, 0);  
  1169.  
  1170.       strip.show();
  1171.       delay (lng);
  1172.  
  1173.       strip.setPixelColor(0, 0, 0, 0);  
  1174.       strip.setPixelColor(1, 255, 255, 255);  
  1175.       strip.setPixelColor(2, 0, 0, 0);  
  1176.       strip.setPixelColor(3, 255, 255, 255);  
  1177.       strip.setPixelColor(4, 0, 0, 0);  
  1178.       strip.setPixelColor(5, 255, 255, 255);  
  1179.       strip.setPixelColor(6, 0, 0, 0);  
  1180.       strip.setPixelColor(7, 255, 255, 255);  
  1181.       strip.setPixelColor(8, 0, 0, 0);  
  1182.       strip.setPixelColor(9, 255, 255, 255);  
  1183.       strip.setPixelColor(10, 0, 0, 0);  
  1184.       strip.setPixelColor (11, 255, 255, 255);  
  1185.  
  1186.       strip.show();
  1187.       delay(lng);
  1188.  
  1189.  
  1190.     }//close option 9
  1191.  
  1192.   }//close if sound level 9
  1193.  
  1194.   else if (soundLevel == 10)
  1195.  
  1196.   {
  1197.     //open if sound Level 10
  1198.  
  1199.     int level10Color = random(1, 8);
  1200.  
  1201.     if (level10Color == 1) //run red
  1202.     {
  1203.       //open option 1
  1204.  
  1205.       strip.setPixelColor(0, 255, 0, 0);  
  1206.       strip.setPixelColor(1, 255, 0, 0);  
  1207.       strip.setPixelColor(2, 255, 0, 0);  
  1208.       strip.setPixelColor(3, 255, 0, 0);  
  1209.       strip.setPixelColor(4, 255, 0, 0);  
  1210.       strip.setPixelColor(5, 255, 0, 0);  
  1211.       strip.setPixelColor(6, 255, 0, 0);  
  1212.       strip.setPixelColor(7, 255, 0, 0);  
  1213.       strip.setPixelColor(8, 255, 0, 0);  
  1214.       strip.setPixelColor(9, 255, 0, 0);  
  1215.       strip.setPixelColor(10, 255, 0, 0);  
  1216.       strip.setPixelColor(11, 0, 0, 0);  
  1217.       strip.show();
  1218.       delay(lng);
  1219.     }//close option 1 red
  1220.  
  1221.     else if (level10Color == 2) //run green
  1222.     {
  1223.       //open option 2
  1224.  
  1225.       strip.setPixelColor(0, 0, 255, 0);  
  1226.       strip.setPixelColor(1, 0, 0, 255);  
  1227.       strip.setPixelColor(2, 0, 255, 0);  
  1228.       strip.setPixelColor(3, 0, 0, 255);  
  1229.       strip.setPixelColor(4, 0, 255, 0);  
  1230.       strip.setPixelColor(5, 0, 0, 255);  
  1231.       strip.setPixelColor(6, 0, 255, 0);  
  1232.       strip.setPixelColor(7, 0, 0, 255);  
  1233.       strip.setPixelColor(8, 0, 255, 0);  
  1234.       strip.setPixelColor(9, 0, 0, 255);  
  1235.       strip.setPixelColor(10, 0, 255, 0);  
  1236.       strip.setPixelColor(11, 0, 0, 0);  
  1237.       strip.show();
  1238.       delay(lng);
  1239.     }//close option 2 green
  1240.  
  1241.     else if (level10Color == 3) //run blue
  1242.     {
  1243.       //open option 3
  1244.  
  1245.       strip.setPixelColor(0, 0, 206, 255);  
  1246.       strip.setPixelColor(1, 0, 0, 255);  
  1247.       strip.setPixelColor(2, 0, 206, 255);  
  1248.       strip.setPixelColor(3, 0, 0, 255);  
  1249.       strip.setPixelColor(4, 0, 206, 255);  
  1250.       strip.setPixelColor(5, 0, 0, 255);  
  1251.       strip.setPixelColor(6, 0, 206, 255);  
  1252.       strip.setPixelColor(7, 0, 0, 255);  
  1253.       strip.setPixelColor(8, 0, 206, 255);  
  1254.       strip.setPixelColor(9, 0, 0, 255);  
  1255.       strip.setPixelColor(10, 0, 206, 255);  
  1256.       strip.setPixelColor(11, 0, 0, 0);  
  1257.       strip.show();
  1258.       delay(lng);
  1259.     }//close option 3 blue
  1260.  
  1261.     else if (level10Color == 4) //run yellow
  1262.     {
  1263.       //open option 4
  1264.  
  1265.       strip.setPixelColor(0, 255, 255, 0);  
  1266.       strip.setPixelColor(1, 255, 255, 0);  
  1267.       strip.setPixelColor(2, 255, 255, 0);  
  1268.       strip.setPixelColor(3, 255, 255, 0);  
  1269.       strip.setPixelColor(4, 255, 255, 0);  
  1270.       strip.setPixelColor(5, 255, 255, 0);  
  1271.       strip.setPixelColor(6, 255, 255, 0);  
  1272.       strip.setPixelColor(7, 255, 255, 0);  
  1273.       strip.setPixelColor(8, 255, 255, 0);  
  1274.       strip.setPixelColor(9, 255, 255, 0);  
  1275.       strip.setPixelColor(10, 255, 255, 0);  
  1276.       strip.setPixelColor(11, 0, 0, 0);  
  1277.       strip.show();
  1278.       delay(lng);
  1279.     }//close option 4 yellow
  1280.  
  1281.     else if (level10Color == 5)
  1282.     {
  1283.       //open option 5
  1284.  
  1285.       colorWipe(strip.Color(200, 40, 147), 50); // pink
  1286.       colorWipe(strip.Color(0, 206, 209), 20); // turquoise
  1287.       strip.show();
  1288.       delay(sht);
  1289.     }//close option 5
  1290.  
  1291.     else if (level10Color == 6)
  1292.     {
  1293.       //open option 6
  1294.       theaterChase(strip.Color(0, 206, 209), 50);
  1295.       strip.show();
  1296.       delay(sht);
  1297.     }//close option 6
  1298.  
  1299.     else if (level10Color == 7)
  1300.     {
  1301.       //open option 7
  1302.       strip.setPixelColor(0, 0, 70, 70);  
  1303.       strip.setPixelColor(1, 0, 100, 0);  
  1304.       strip.setPixelColor(2, 255, 0, 70);  
  1305.       strip.setPixelColor(3, 50, 0, 150);  
  1306.       strip.setPixelColor(4, 0, 70, 70);  
  1307.       strip.setPixelColor(5, 0, 100, 0);  
  1308.       strip.setPixelColor(6, 255, 0, 70);  
  1309.       strip.setPixelColor(7, 50, 0, 150);  
  1310.       strip.setPixelColor(8, 255, 0, 70);  
  1311.       strip.setPixelColor(9, 0, 100, 0);  
  1312.       strip.setPixelColor(10, 255, 0, 70);  
  1313.       strip.setPixelColor(11, 50, 0, 150);  
  1314.  
  1315.       strip.show();
  1316.       delay(lng);
  1317.  
  1318.       strip.setPixelColor(0, 0, 255, 255);  
  1319.       strip.setPixelColor(1, 0, 255, 255);  
  1320.       strip.setPixelColor(2, 0, 0, 0);  
  1321.       strip.setPixelColor(3, 255, 255, 0);  
  1322.       strip.setPixelColor(4, 255, 255, 0);  
  1323.       strip.setPixelColor(5, 0, 0, 0);  
  1324.       strip.setPixelColor(6, 0, 255, 255);  
  1325.       strip.setPixelColor(7, 0, 255, 255);  
  1326.       strip.setPixelColor(8, 0, 0, 0);  
  1327.       strip.setPixelColor(9, 255, 255, 0);  
  1328.       strip.setPixelColor(10, 255, 255, 0);  
  1329.       strip.setPixelColor(11, 0, 0, 0);  
  1330.       strip.show();
  1331.       delay(lng);
  1332.  
  1333.       strip.setPixelColor(0, 255, 255, 255);  
  1334.       strip.setPixelColor(1, 255, 255, 255);  
  1335.       strip.setPixelColor(2, 255, 255, 255);  
  1336.       strip.setPixelColor(3, 255, 255, 255);  
  1337.       strip.setPixelColor(4, 255, 255, 255);  
  1338.       strip.setPixelColor(5, 255, 255, 255);  
  1339.       strip.setPixelColor(6, 255, 255, 255);  
  1340.       strip.setPixelColor(7, 255, 255, 255);  
  1341.       strip.setPixelColor(8, 255, 255, 255);  
  1342.       strip.setPixelColor(9, 255, 255, 255);  
  1343.       strip.setPixelColor(10, 255, 255, 255);  
  1344.       strip.setPixelColor(11, 255, 255, 255);  
  1345.       strip.show();
  1346.       delay(sht);
  1347.  
  1348.     }//close option 7
  1349.  
  1350.   }//close if sound level 10
  1351.  
  1352.  
  1353.   else if (soundLevel == 11)
  1354.  
  1355.   {
  1356.     //open if sound Level 11
  1357.  
  1358.     int level11Color = random(1, 8);
  1359.  
  1360.     if (level11Color == 1) //run red
  1361.     {
  1362.       //open option 1
  1363.  
  1364.       strip.setPixelColor(0, 255, 0, 0);  
  1365.       strip.setPixelColor(1, 255, 0, 0);  
  1366.       strip.setPixelColor(2, 255, 0, 0);  
  1367.       strip.setPixelColor(3, 255, 0, 0);  
  1368.       strip.setPixelColor(4, 255, 0, 0);  
  1369.       strip.setPixelColor(5, 255, 0, 0);  
  1370.       strip.setPixelColor(6, 255, 0, 0);  
  1371.       strip.setPixelColor(7, 255, 0, 0);  
  1372.       strip.setPixelColor(8, 255, 0, 0);  
  1373.       strip.setPixelColor(9, 255, 0, 0);  
  1374.       strip.setPixelColor(10, 255, 0, 0);  
  1375.       strip.setPixelColor(11, 255, 0, 0);  
  1376.       strip.show();
  1377.       delay(lng);
  1378.     }//close option 1 red
  1379.  
  1380.     else if (level11Color == 2) //run green
  1381.     {
  1382.       //open option 2
  1383.  
  1384.       strip.setPixelColor(0, 0, 255, 0);  
  1385.       strip.setPixelColor(1, 0, 0, 255);  
  1386.       strip.setPixelColor(2, 0, 255, 0);  
  1387.       strip.setPixelColor(3, 0, 0, 255);  
  1388.       strip.setPixelColor(4, 0, 255, 0);  
  1389.       strip.setPixelColor(5, 0, 0, 255);  
  1390.       strip.setPixelColor(6, 0, 255, 0);  
  1391.       strip.setPixelColor(7, 0, 0, 255);  
  1392.       strip.setPixelColor(8, 0, 255, 0);  
  1393.       strip.setPixelColor(9, 0, 0, 255);  
  1394.       strip.setPixelColor(10, 0, 255, 0);  
  1395.       strip.setPixelColor(11, 0, 0, 255);  
  1396.       strip.show();
  1397.       delay(lng);
  1398.     }//close option 2  green
  1399.  
  1400.     else if (level11Color == 3) //run blue
  1401.     {
  1402.       //open option 3
  1403.  
  1404.       strip.setPixelColor(0, 0, 206, 255);  
  1405.       strip.setPixelColor(1, 0, 0, 255);  
  1406.       strip.setPixelColor(2, 0, 206, 255);  
  1407.       strip.setPixelColor(3, 0, 0, 255);  
  1408.       strip.setPixelColor(4, 0, 206, 255);  
  1409.       strip.setPixelColor(5, 0, 0, 255);  
  1410.       strip.setPixelColor(6, 0, 206, 255);  
  1411.       strip.setPixelColor(7, 0, 0, 255);  
  1412.       strip.setPixelColor(8, 0, 206, 255);  
  1413.       strip.setPixelColor(9, 0, 0, 255);  
  1414.       strip.setPixelColor(10, 0, 206, 255);  
  1415.       strip.setPixelColor(11, 0, 0, 255);  
  1416.       strip.show();
  1417.       delay(lng);
  1418.     }//close option 3 blue
  1419.  
  1420.     else if (level11Color == 4) //run yellow
  1421.     {
  1422.       //open option 4
  1423.  
  1424.       strip.setPixelColor(0, 255, 255, 0);  
  1425.       strip.setPixelColor(1, 255, 255, 0);  
  1426.       strip.setPixelColor(2, 255, 255, 0);  
  1427.       strip.setPixelColor(3, 255, 255, 0);  
  1428.       strip.setPixelColor(4, 255, 255, 0);  
  1429.       strip.setPixelColor(5, 255, 255, 0);  
  1430.       strip.setPixelColor(6, 255, 255, 0);  
  1431.       strip.setPixelColor(7, 255, 255, 0);  
  1432.       strip.setPixelColor(8, 255, 255, 0);  
  1433.       strip.setPixelColor(9, 255, 255, 0);  
  1434.       strip.setPixelColor(10, 255, 255, 0);  
  1435.       strip.setPixelColor(11, 255, 255, 0);  
  1436.       strip.show();
  1437.       delay(lng);
  1438.     }//close option 4 yellow
  1439.  
  1440.     else if (level11Color == 5)
  1441.     {
  1442.       //open option 5
  1443.  
  1444.       colorWipe(strip.Color(0, 40, 255), 50); // pink
  1445.       colorWipe(strip.Color(0, 209, 206), 20); // turquoise
  1446.       strip.show();
  1447.       delay(sht);
  1448.     }//close option 5
  1449.  
  1450.     else if (level11Color == 6) //open option 6
  1451.     {
  1452.       //open option 6
  1453.       theaterChase(strip.Color(0, 206, 109), 50);
  1454.       strip.show();
  1455.       delay(sht);
  1456.     }//close option 6
  1457.  
  1458.     else if (level11Color == 7)//open option 7
  1459.     {
  1460.       //open option 7
  1461.       strip.setPixelColor(0, 0, 70, 70);  
  1462.       strip.setPixelColor(1, 0, 100, 0);  
  1463.       strip.setPixelColor(2, 255, 0, 70);  
  1464.       strip.setPixelColor(3, 50, 0, 150);  
  1465.       strip.setPixelColor(4, 0, 70, 70);  
  1466.       strip.setPixelColor(5, 0, 100, 0);  
  1467.       strip.setPixelColor(6, 255, 0, 70);  
  1468.       strip.setPixelColor(7, 50, 0, 150);  
  1469.       strip.setPixelColor(8, 255, 0, 70);  
  1470.       strip.setPixelColor(9, 0, 100, 0);  
  1471.       strip.setPixelColor(10, 255, 0, 70);  
  1472.       strip.setPixelColor(11, 50, 0, 150);  
  1473.  
  1474.       strip.show();
  1475.       delay(lng);
  1476.  
  1477.       strip.setPixelColor(0, 0, 255, 255);  
  1478.       strip.setPixelColor(1, 0, 255, 255);  
  1479.       strip.setPixelColor(2, 0, 0, 0);  
  1480.       strip.setPixelColor(3, 255, 255, 0);  
  1481.       strip.setPixelColor(4, 255, 255, 0);  
  1482.       strip.setPixelColor(5, 0, 0, 0);  
  1483.       strip.setPixelColor(6, 0, 255, 255);  
  1484.       strip.setPixelColor(7, 0, 255, 255);  
  1485.       strip.setPixelColor(8, 0, 0, 0);  
  1486.       strip.setPixelColor(9, 255, 255, 0);  
  1487.       strip.setPixelColor(10, 255, 255, 0);  
  1488.       strip.setPixelColor(11, 0, 0, 0);  
  1489.       strip.show();
  1490.       delay(lng);
  1491.  
  1492.       strip.setPixelColor(0, 255, 255, 255);  
  1493.       strip.setPixelColor(1, 255, 255, 255);  
  1494.       strip.setPixelColor(2, 255, 255, 255);  
  1495.       strip.setPixelColor(3, 255, 255, 255);  
  1496.       strip.setPixelColor(4, 255, 255, 255);  
  1497.       strip.setPixelColor(5, 255, 255, 255);  
  1498.       strip.setPixelColor(6, 255, 255, 255);  
  1499.       strip.setPixelColor(7, 255, 255, 255);  
  1500.       strip.setPixelColor(8, 255, 255, 255);  
  1501.       strip.setPixelColor(9, 255, 255, 255);  
  1502.       strip.setPixelColor(10, 255, 255, 255);  
  1503.       strip.setPixelColor(11, 255, 255, 255);  
  1504.       strip.show();
  1505.       delay(lng);
  1506.  
  1507.       strip.setPixelColor(0, 0, 255, 255);  
  1508.       strip.setPixelColor(1, 0, 255, 255);  
  1509.       strip.setPixelColor(2, 0, 0, 0);  
  1510.       strip.setPixelColor(3, 255, 255, 0);  
  1511.       strip.setPixelColor(4, 255, 255, 0);  
  1512.       strip.setPixelColor(5, 0, 0, 0);  
  1513.       strip.setPixelColor(6, 0, 255, 255);  
  1514.       strip.setPixelColor(7, 0, 255, 255);  
  1515.       strip.setPixelColor(8, 0, 0, 0);  
  1516.       strip.setPixelColor(9, 255, 255, 0);  
  1517.       strip.setPixelColor(10, 255, 255, 0);  
  1518.       strip.setPixelColor(11, 0, 0, 0);  
  1519.       strip.show();
  1520.       delay(lng);
  1521.  
  1522.     }//close option 7
  1523.  
  1524.   }//close if sound level 11
  1525.  
  1526. }//close void loop()
  1527.  
  1528. //neopixel functions below
  1529.  
  1530.  
  1531.  
  1532. void colorWipe(uint32_t c, uint8_t wait)
  1533. {
  1534.   //open colowipe
  1535.   for(uint16_t i = 0; i < strip.numPixels(); i++)
  1536.   {
  1537.     strip.setPixelColor(i, c);
  1538.     strip.show();
  1539.     delay(wait);
  1540.   }
  1541. }//close colorWipe function
  1542.  
  1543. void theaterChase(uint32_t c, uint8_t wait)
  1544. {
  1545.   //open theaterchase function
  1546.   for (int j = 0; j < 3; j++) //do 3 cycles of chasing
  1547.   {
  1548.     for (int q = 0; q < 3; q++)
  1549.     {
  1550.       for (int i = 0; i < strip.numPixels(); i = i + 3)
  1551.       {
  1552.         strip.setPixelColor(i + q, c);  //turn every third pixel on
  1553.       }
  1554.       strip.show();
  1555.  
  1556.       delay(wait);
  1557.  
  1558.       for (int i = 0; i < strip.numPixels(); i = i + 3)
  1559.       {
  1560.         strip.setPixelColor(i + q, 0);      //turn every third pixel off
  1561.       }
  1562.     }
  1563.   }
  1564. }//close theater chase function
  1565.  
  1566. void rainbowCycle(uint8_t wait)  //open rainbow function
  1567. {
  1568.   uint16_t i, j;
  1569.  
  1570.   for(j = 0; j < 256; j++) // 1 cycles of all colors on wheel
  1571.   {
  1572.     for(i = 0; i < strip.numPixels(); i++)
  1573.     {
  1574.       strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
  1575.     }
  1576.     strip.show();
  1577.     delay(wait);
  1578.   }
  1579. }//close rainbow function
  1580. //you need to included the code below for the neopixel functions that use the 'wheel' code:
  1581. uint32_t Wheel(byte WheelPos)
  1582. {
  1583.   WheelPos = 255 - WheelPos;
  1584.   if(WheelPos < 85)
  1585.   {
  1586.     return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  1587.   }
  1588.   if(WheelPos < 170)
  1589.   {
  1590.     WheelPos -= 85;
  1591.     return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  1592.   }
  1593.   WheelPos -= 170;
  1594.   return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  1595. }
  1596.  
  1597. //end
A hozzászólás módosítva: Márc 4, 2021
Moderátor által szerkesztve
(#) dB_Thunder válasza dB_Thunder hozzászólására (») Márc 3, 2021 /
 
Itt van még egy 7 sávos kódja, forrás: HeinzKetschup
  1. //https://create.arduino.cc/projecthub/HeinzKetschup/spectrum-analyzer-with-rgb-leds-eb9785
  2. //Arduino Spectrum Analyzer with RGB-LED Stripe and MSGEQ7 by HeinzKetchup
  3. // declarations for the Neopixel by Adafruit
  4. #include <Adafruit_NeoPixel.h>
  5. #ifdef __AVR__
  6. #include <avr/power.h>
  7. #endif
  8. #define PIN 4 // Pin for the RGB Stripe
  9. #define NUMPIXELS 70  // Number of Pixels
  10. Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
  11. int strobePin = 2;  // Strobe Pin on the MSGEQ7
  12. int resetPin = 3; // Reset Pin on the MSGEQ7
  13. int outPin = A0;  // Output Pin on the MSGEQ7
  14. int level[7]; // An array to hold the values from the 7 frequency bands
  15. int l;
  16. uint32_t aus =  pixels.Color(0,0,0);
  17. uint32_t gr =  pixels.Color(0,200,0);
  18. uint32_t grb =  pixels.Color(0,160,40);
  19. uint32_t grbl =  pixels.Color(0,120,80);
  20. uint32_t gbl =  pixels.Color(0,80,120);
  21. uint32_t bl =  pixels.Color(0,40,160);
  22. uint32_t blr =  pixels.Color(0,0,200);
  23. uint32_t blro =  pixels.Color(40,0,160);
  24. uint32_t bro =  pixels.Color(80,0,120);
  25. uint32_t ro =  pixels.Color(120,0,80);
  26. uint32_t rog =  pixels.Color(160,0,0);
  27.  
  28. void setup()
  29. {
  30.   Serial.begin(9600);
  31.   pinMode(strobePin, OUTPUT); // Define our pin modes
  32.   pinMode(resetPin,  OUTPUT);
  33.   pinMode(outPin, INPUT);
  34.   pinMode(3,OUTPUT);
  35.   digitalWrite(resetPin, LOW);  // Create an initial state for our pins
  36.   digitalWrite(strobePin, LOW);
  37.   delay(1);
  38.   digitalWrite(resetPin, HIGH); // Reset the MSGEQ7 as per the datasheet timing diagram
  39.   delay(1);
  40.   digitalWrite(resetPin, LOW);
  41.   digitalWrite(strobePin, HIGH);
  42.   delay(1);
  43.   pixels.begin(); // enables Adafruit Neopixels
  44.   pixels.show();  // reset Pixels
  45.   for (int i = 0; i < 70; i++)
  46.   {
  47.     int ii = i-5; //snake effect at the start
  48.     pixels.setPixelColor(i, gr);
  49.     pixels.setPixelColor(ii, aus);
  50.     pixels.show();
  51.     delay(20);
  52.   }
  53. }
  54. void LEDaus1(int a,int b,int c,int d,int e,int f,int g,int h,int j,int k)
  55. {
  56.    for (int i=a; i <=k; i++)
  57.    {                      
  58.     pixels.setPixelColor(i, aus);
  59.     pixels.show();
  60.    }
  61. }
  62. void LEDaus2(int a,int b,int c,int d,int e,int f,int g,int h,int j,int k)
  63. {
  64.    for (int i=a; i >=k; i--)
  65.    {                      
  66.     pixels.setPixelColor(i, aus);
  67.     pixels.show();
  68.    }
  69. }
  70. void LED0(int a,int b,int c,int d,int e,int f,int g,int h,int j,int k, uint32_t gr)
  71. {
  72.  pixels.setPixelColor(a, gr);
  73.  for (int i=b; i <= k; i++) pixels.setPixelColor(i, aus);
  74. }
  75. void LED1(int a,int b,int c,int d,int e,int f,int g,int h,int j,int k)
  76. {
  77.  pixels.setPixelColor(a, gr);    
  78.  pixels.setPixelColor(b, grb);
  79.  for (int i=k; i <= c; i++) pixels.setPixelColor(i, aus);
  80. }
  81. void LED2(int a,int b,int c,int d,int e,int f,int g,int h,int j,int k)
  82. {
  83.  pixels.setPixelColor(a, gr);
  84.  pixels.setPixelColor(b, grb);
  85.  pixels.setPixelColor(c, grbl);
  86.  for (int i=d; i <= k; i++) pixels.setPixelColor(i, aus);
  87. }
  88. void LED3(int a,int b,int c,int d,int e,int f,int g,int h,int j,int k)
  89. {
  90.  pixels.setPixelColor(a, gr);
  91.  pixels.setPixelColor(b, grb);
  92.  pixels.setPixelColor(c, grbl);
  93.  pixels.setPixelColor(d, gbl);
  94.  for (int i=k; i <= e; i++) pixels.setPixelColor(i, aus);
  95. }
  96. void LED4(int a,int b,int c,int d,int e,int f,int g,int h,int j,int k)
  97. {
  98.  pixels.setPixelColor(a, gr);
  99.  pixels.setPixelColor(b, grb);
  100.  pixels.setPixelColor(c, grbl);
  101.  pixels.setPixelColor(d, gbl);
  102.  pixels.setPixelColor(e, bl);
  103.  for (int i=f; i <= k; i++) pixels.setPixelColor(i, aus);
  104. }
  105. void LED5(int a,int b,int c,int d,int e,int f,int g,int h,int j,int k)
  106. {
  107.  pixels.setPixelColor(a, gr);
  108.  pixels.setPixelColor(b, grb);
  109.  pixels.setPixelColor(c, grbl);
  110.  pixels.setPixelColor(d, gbl);
  111.  pixels.setPixelColor(e, bl);
  112.  pixels.setPixelColor(f, blr);
  113.  for (int i=k; i <= g; i++) pixels.setPixelColor(i, aus);
  114. }
  115. void LED6(int a,int b,int c,int d,int e,int f,int g,int h,int j,int k)
  116. {
  117.  pixels.setPixelColor(a, gr);
  118.  pixels.setPixelColor(b, grb);
  119.  pixels.setPixelColor(c, grbl);
  120.  pixels.setPixelColor(d, gbl);
  121.  pixels.setPixelColor(e, bl);
  122.  pixels.setPixelColor(f, blr);
  123.  pixels.setPixelColor(g, blro);
  124.  for (int i=h; i <= k; i++) pixels.setPixelColor(i, aus);
  125. }
  126. void LED7(int a,int b,int c,int d,int e,int f,int g,int h,int j,int k)
  127. {
  128.  pixels.setPixelColor(a, gr);
  129.  pixels.setPixelColor(b, grb);
  130.  pixels.setPixelColor(c, grbl);
  131.  pixels.setPixelColor(d, gbl);
  132.  pixels.setPixelColor(e, bl);
  133.  pixels.setPixelColor(f, blr);
  134.  pixels.setPixelColor(g, blro);
  135.  pixels.setPixelColor(h, bro);
  136.  for (int i=k; i <= j; i++) pixels.setPixelColor(i, aus);
  137. }
  138. void LED8(int a,int b,int c,int d,int e,int f,int g,int h,int j,int k)
  139. {
  140.  pixels.setPixelColor(a, gr);
  141.  pixels.setPixelColor(b, grb);
  142.  pixels.setPixelColor(c, grbl);
  143.  pixels.setPixelColor(d, gbl);
  144.  pixels.setPixelColor(e, bl);
  145.  pixels.setPixelColor(f, blr);
  146.  pixels.setPixelColor(g, blro);
  147.  pixels.setPixelColor(h, bro);
  148.  pixels.setPixelColor(j, ro);
  149.  pixels.setPixelColor(k, aus);
  150. }
  151. void LED9(int a,int b,int c,int d,int e,int f,int g,int h,int j,int k)
  152. {
  153.  pixels.setPixelColor(a, gr);
  154.  pixels.setPixelColor(b, grb);
  155.  pixels.setPixelColor(c, grbl);
  156.  pixels.setPixelColor(d, gbl);
  157.  pixels.setPixelColor(e, bl);
  158.  pixels.setPixelColor(f, blr);
  159.  pixels.setPixelColor(g, blro);
  160.  pixels.setPixelColor(h, bro);
  161.  pixels.setPixelColor(j, ro);
  162.  pixels.setPixelColor(k, rog);
  163. }
  164. void abfolge(int a,int b,int c,int d,int e,int f,int g,int h,int j,int k)
  165. {
  166.  switch (l)
  167.  {
  168.   case 93 ... 104:/*<---------------------------------------first LED area--------------------------------------------------------*/
  169.   LED0(a,b,c,d,e,f,g,h,j,k,gr);
  170.   break;
  171.   case 105 ... 139:/*<---------------------------------------second LED area------------------------------------------------------*/
  172.   LED1(a,b,c,d,e,f,g,h,j,k);
  173.   break;
  174.   case 140 ... 164:/*<---------------------------------------third LED area-------------------------------------------------------*/    
  175.   LED2(a,b,c,d,e,f,g,h,j,k);
  176.   break;
  177.   case 165 ... 199:/*<---------------------------------------fourth LED area------------------------------------------------------*/
  178.   LED3(a,b,c,d,e,f,g,h,j,k);
  179.   break;
  180.   case 200 ... 234:/*<---------------------------------------fith LED area--------------------------------------------------------*/
  181.   LED4(a,b,c,d,e,f,g,h,j,k);
  182.   break;
  183.   case 235 ... 269:/*<---------------------------------------sixth LED area-------------------------------------------------------*/
  184.   LED5(a,b,c,d,e,f,g,h,j,k);
  185.   break;
  186.   case 270 ... 304:/*<---------------------------------------seventh LED area-----------------------------------------------------*/
  187.   LED6(a,b,c,d,e,f,g,h,j,k);
  188.   break;
  189.   case 305 ... 339:/*<---------------------------------------eighth LED area------------------------------------------------------*/
  190.   LED7(a,b,c,d,e,f,g,h,j,k);
  191.   break;
  192.   case 340 ... 374:/*<---------------------------------------nineth LED area------------------------------------------------------*/
  193.   LED8(a,b,c,d,e,f,g,h,j,k);
  194.   break;
  195.   case 375 ... 1000:/*<---------------------------------------tenth LED area------------------------------------------------------*/  
  196.   LED9(a,b,c,d,e,f,g,h,j,k);
  197.   break;    
  198.  }
  199. }
  200. void loop()
  201. {
  202.  // Cycle through each frequency band by pulsing the strobe.
  203.  for (int i = 0; i < 7; i++)
  204.  {
  205.   digitalWrite       (strobePin, LOW);
  206.   delayMicroseconds  (100);                    // Delay necessary due to timing diagram
  207.   level[i] =         analogRead (outPin);
  208.   digitalWrite       (strobePin, HIGH);
  209.   delayMicroseconds  (100);                    // Delay necessary due to timing diagram  
  210.  }
  211.  /*-----------------------------------------------------------Band1(For the first LED stripe)---------------------------------------------------------------*/                  
  212.  // allocation for the Numbers of LEDs
  213.  l = level [0];
  214.  abfolge(0,1,2,3,4,5,6,7,8,9);
  215.  if (l < 92) LEDaus1(0,1,2,3,4,5,6,7,8,9);
  216.  /*-----------------------------------------------------------Band2(For the second LED stripe)---------------------------------------------------------------*/                    
  217.  // allocation for the Numbers of LEDs
  218.  l = level [1];
  219.  abfolge(19,18,17,16,15,14,13,12,11,10);
  220.  if (l < 92) LEDaus2(19,18,17,16,15,14,13,12,11,10);
  221.  /*-----------------------------------------------------------Band3(For the third LED stripe)---------------------------------------------------------------*/                    
  222.  // allocation for the Numbers of LEDs
  223.  l = level [2];
  224.  abfolge(20,21,22,23,24,25,26,27,28,29);
  225.  if (l < 92) LEDaus1(20,21,22,23,24,25,26,27,28,29);
  226.  /*-----------------------------------------------------------Band4(For the fourth LED stripe)---------------------------------------------------------------*/                    
  227.  // allocation for the Numbers of LEDs
  228.  l = level [3];
  229.  abfolge(39,38,37,36,35,34,33,32,31,30);
  230.  if (l < 92) LEDaus2(39,38,37,36,35,34,33,32,31,30);  
  231.  /*-----------------------------------------------------------Band5(For the fifth LED stripe)---------------------------------------------------------------*/                      
  232.  // allocation for the Numbers of LEDs
  233.  l = level [4];
  234.  abfolge(40,41,42,43,44,45,46,47,48,49);
  235.  if (l < 92) LEDaus1(40,41,42,43,44,45,46,47,48,49);  
  236.  /*-----------------------------------------------------------Band6(For the sixth LED stripe)---------------------------------------------------------------*/                    
  237.  // allocation for the Numbers of LEDs
  238.  l = level [5];
  239.  abfolge(59,58,57,56,55,54,53,52,51,50);
  240.  if (l < 92) LEDaus2(59,58,57,56,55,54,53,52,51,50);  
  241.  /*-----------------------------------------------------------Band7(For the seventh LED stripe)---------------------------------------------------------------*/                      
  242.  // allocation for the Numbers of LEDs
  243.  l = level [6];            
  244.  abfolge(60,61,62,63,64,65,66,67,68,69);
  245.  if (l < 92) LEDaus1(60,61,62,63,64,65,66,67,68,69);                            
  246. }
A hozzászólás módosítva: Márc 3, 2021
(#) dB_Thunder válasza dB_Thunder hozzászólására (») Márc 3, 2021 /
 
Egy orosz megoldás! Ez sem tud komoly animációt, viszont a videóban mintha a led szalagra merőlegesen villognának az oszlopok! Ezt sem próbáltam még.

cxem.net
  1. #include "Adafruit_NeoPixel.h"
  2. #define PIN 6
  3.  
  4. // Parameter 1 = number of pixels in strip
  5. // Parameter 2 = Arduino pin number (most are valid)
  6. // Parameter 3 = pixel type flags, add together as needed:
  7. //   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
  8. //   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
  9. //   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
  10. //   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
  11. Adafruit_NeoPixel strip = Adafruit_NeoPixel(150, PIN, NEO_GRB + NEO_KHZ800);
  12.  
  13. #define MAX_X 10
  14. #define MAX_Y 15
  15.  
  16. byte maska[135]={
  17.    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  18.    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  19.    0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
  20.    0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,
  21.    0,1,1,0,0,0,0,1,0,0,0,0,1,1,1,
  22.    0,1,1,0,0,0,1,1,1,0,0,1,1,1,1,
  23.    0,1,1,0,1,1,1,1,1,0,0,1,1,1,1,
  24.    0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  25.    0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  26.    };
  27. int colors[14][3]={{0,150,0},{0,255,0},
  28.                    {100,255,0},{255,255,0},
  29.                    {150,0,0},{255,0,0},
  30.                    {255,0,100},{255,0,255},
  31.                    {150,0,255},{0,0,255},
  32.                    {0,0,150},{0,150,255},
  33.                    {0,255,255},{0,255,100}
  34.                    };
  35. int offcolor=0;
  36. unsigned long millis1=0;
  37. // плохие светодиоды
  38. int badleds[]={0,1,15,30};
  39.  
  40.  
  41. //
  42. #define msg7RESET 11
  43. #define msg7Strobe 12
  44. #define msg7DCout 0
  45.  
  46. int arr1[7]={0,0,0,0,0,0,0};
  47.  
  48.  
  49. void setup() {
  50.   Serial.begin(9600);
  51.   pinMode(msg7RESET, OUTPUT);
  52.   pinMode(msg7Strobe, OUTPUT);
  53.   strip.begin();
  54.   for(int i=0;i<135;i++)
  55.     {
  56.     correctstrip(i,0,0,0);
  57.     }
  58.   strip.show();
  59.   Serial.println("oksetup");
  60.   }
  61.  
  62. void loop() {
  63.     digitalWrite(msg7RESET, HIGH);   // осуществляем сброс MSGEQ7
  64.     delay(5);
  65.     digitalWrite(msg7RESET, LOW);
  66.  
  67.     for (int x = 0; x < 7; x++){             // семь частот - семь стробирующих импульсов
  68.         digitalWrite(msg7Strobe, LOW);
  69.         delayMicroseconds(35);           // ждем установления значения 35 мкс
  70.         int spectrumRead = analogRead(A0);      // считываем значение с аналогового входа
  71.  
  72.         int PWMvalue = map(spectrumRead, 0, 1024, 0, 255);  // преобразовываем диапазон 0-1024 к диапазону 0-255 для ШИМ
  73.         setVals(x,PWMvalue);
  74.         arr1[x]=spectrumRead;
  75.          digitalWrite(msg7Strobe, HIGH);
  76.     }
  77.     for(int i=0;i<7;i++)
  78.       {Serial.print(" ");Serial.print(arr1[i]);}
  79.     Serial.println();
  80.  
  81.   strip.show();
  82.   if(millis()-millis1>1000)
  83.     {millis1=millis();offcolor=(offcolor+1)%7;
  84.     }  
  85. }
  86. /////
  87. //удалить испорченные
  88. void correctstrip(int place,int color1,int color2,int color3)
  89.   {
  90.   int offset=0;
  91.   for(int i=0;i=j*28)
  92.        {
  93.        correctstrip((9-j)*15+i*2+1,colors[((i+offcolor)%7)*2][0],colors[((i+offcolor)%7)*2][1],colors[((i+offcolor)%7)*2][2]);
  94.        correctstrip((9-j)*15+i*2+2,colors[((i+offcolor)%7)*2+1][0],colors[((i+offcolor)%7)*2+1][1],colors[((i+offcolor)%7)*2+1][2]);
  95.        }
  96.     else
  97.       {
  98.       correctstrip((9-j)*15+i*2+1,0,0,0);      
  99.       correctstrip((9-j)*15+i*2+2,0,0,0);      
  100.       }  
  101.     }  
  102.   }
A hozzászólás módosítva: Márc 3, 2021
(#) dB_Thunder válasza dB_Thunder hozzászólására (») Márc 6, 2021 /
 
Még egy kód. A forrásra már nem találtam vissza, franc se tudja hol találtam. Csak 7 csatorna viszont valami infra távot is kezel! Filenév: FNMJOTIJA8JN8KZ.ino

  1. #include <FastLED.h>
  2. #include <IRLib.h>
  3.  
  4. int analogPin = 0; //msgeq7 pin 3
  5. int strobePin = 2; //msgeq7 pin 4
  6. int resetPin = 3; // msgeq7 pin 7
  7. int spectrumValue[7]; //array to hold values
  8.  
  9. int minval = 90;
  10. int maxval = 900;
  11.  
  12. boolean mode = 1; //by Default, play matrix animation
  13.  
  14. ///////////////////////////IR Receiver///////////////////////////
  15. int recv_pin = 11;
  16. IRrecv My_Receiver(recv_pin);
  17. IRdecode My_Decoder;
  18. IRdecodeHash My_Hash_Decoder;
  19. /////////////////////////IR Receiver End/////////////////////////
  20.  
  21. /////////////////////////////For Matrix/////////////////////////////
  22. #define UPDATES_PER_SECOND 100
  23. #define BRIGHTNESS  255
  24. #define COLOR_ORDER GRB
  25.  
  26. CRGBPalette16 currentPalette;
  27. TBlendType    currentBlending;
  28.  
  29. extern CRGBPalette16 myRedWhiteBluePalette;
  30. extern const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM;
  31. /////////////////////////////For Matrix End/////////////////////////////
  32.  
  33. //The amount of LEDs in the setup
  34. #define NUM_LEDS 49
  35. //The pin that controls the LEDs
  36. #define LED_PIN 8
  37. //No of LEDs in a column
  38. int NUM_LEDS_SINGLE = (NUM_LEDS / 7);
  39.  
  40. //Led array
  41. CRGB leds[NUM_LEDS];
  42.  
  43. //How many previous sensor values effects the operating average?
  44. #define AVGLEN 5
  45. //How many previous sensor values decides if we are on a peak/HIGH (e.g. in a song)
  46. #define LONG_SECTOR 20
  47.  
  48. //Mnemonics
  49. #define HIGH 3
  50. #define NORMAL 2
  51.  
  52. //How long do we keep the "current average" sound, before restarting the measuring
  53. #define MSECS 30 * 1000
  54. #define CYCLES MSECS / DELAY
  55.  
  56. /*Sometimes readings are wrong or strange. How much is a reading allowed
  57.   to deviate from the average to not be discarded? **/
  58. #define DEV_THRESH 0.8
  59.  
  60. //Arduino loop delay
  61. #define DELAY 1
  62.  
  63. float fscale( float originalMin, float originalMax, float newBegin, float newEnd, float inputValue, float curve);
  64. void insert(int val, int *avgs, int len);
  65. int compute_average(int *avgs, int len);
  66. void visualize_music(int specVal, int row_no);
  67.  
  68. //How many LEDs do we display
  69. int curshow = NUM_LEDS_SINGLE;
  70.  
  71. //Showing different colors based on the mode.
  72. int songmode = NORMAL;
  73.  
  74. //Average sound measurement the last CYCLES
  75. unsigned long song_avg;
  76.  
  77. //The amount of iterations since the song_avg was reset
  78. int iter = 0;
  79.  
  80. //The speed the LEDs fade to black if not relit
  81. float fade_scale = 1.2;
  82.  
  83. /*Short sound avg used to "normalize" the input values.
  84.   We use the short average instead of using the sensor input directly */
  85. int avgs[AVGLEN] = { -1};
  86.  
  87. //Longer sound avg
  88. int long_avg[LONG_SECTOR] = { -1};
  89.  
  90. //Keeping track how often, and how long times we hit a certain mode
  91. struct time_keeping {
  92.   unsigned long times_start;
  93.   short times;
  94. };
  95.  
  96. //How much to increment or decrement each color every cycle
  97. struct color {
  98.   int r;
  99.   int g;
  100.   int b;
  101. };
  102.  
  103. struct time_keeping high;
  104. struct color Color;
  105.  
  106. /////////////////////////////Setup/////////////////////////////
  107. void setup() {
  108.   // put your setup code here, to run once:
  109.   delay( 3000 );
  110.   Serial.begin(9600);
  111.  
  112.   My_Receiver.enableIRIn(); // Start the receiver
  113.  
  114.   pinMode(analogPin, INPUT);
  115.   pinMode(strobePin, OUTPUT);
  116.   pinMode(resetPin, OUTPUT);
  117.   digitalWrite(resetPin, LOW);
  118.   digitalWrite(strobePin, 1);
  119.  
  120.   FastLED.addLeds<NEOPIXEL, LED_PIN>(leds, NUM_LEDS);
  121.  
  122.   //bootstrap average with some low values
  123.   for (int i = 0; i < AVGLEN; i++) {
  124.     insert(250, avgs, AVGLEN);
  125.   }
  126.  
  127.   //Initial values
  128.   high.times = 0;
  129.   high.times_start = millis();
  130.   Color.r = 0;
  131.   Color.g = 0;
  132.   Color.b = 1;
  133.  
  134.   //delay(1000);
  135.  
  136.   currentPalette = RainbowColors_p;
  137.   currentBlending = LINEARBLEND;
  138. }
  139. /////////////////////////////Setup End/////////////////////////////
  140.  
  141. ///////////////////////////////Loop///////////////////////////////
  142. void loop() {
  143.   // put your main code here, to run repeatedly:
  144.   if (My_Receiver.GetResults(&My_Decoder))
  145.   {
  146.     My_Hash_Decoder.copyBuf(&My_Decoder);
  147.     My_Decoder.decode();
  148.     float hexvalue = My_Decoder.value;
  149.  
  150.     if (hexvalue == 0x1fe48b7)
  151.     { mode = !mode;
  152. //      for (int q = 0; q < 50; q++)m
  153. //      {
  154. //        leds[q] = CRGB::Black;
  155. //      }
  156.     }
  157.  
  158.     if (mode == 1) {
  159.       digitalWrite(resetPin, 1);
  160.       digitalWrite(resetPin, 0);
  161.       for (int i = 0; i < 7; i++) {
  162.         digitalWrite(strobePin, 0);
  163.         delay(30);
  164.         spectrumValue[i] = analogRead(analogPin);
  165.         digitalWrite(strobePin, 1);
  166.       }
  167.       ///////////////Change values here for test///////////////
  168.       for (int p = 0; p < 7; p++)
  169.       {
  170.         visualize_music(spectrumValue[p], p);
  171.         Serial.print(spectrumValue[p]);
  172.         Serial.print(" ");
  173.       }
  174.       Serial.println();
  175.       /////////////////Check in serial monitor/////////////////
  176.     }
  177.     else
  178.     {
  179.       Serial.println("Here I am!");
  180.       ChangePalettePeriodically();
  181.  
  182.       static uint8_t startIndex = 0;
  183.       startIndex = startIndex + 1; /* motion speed */
  184.  
  185.       FillLEDsFromPaletteColors( startIndex);
  186.  
  187.       FastLED.show();
  188.       FastLED.delay(1000 / UPDATES_PER_SECOND);
  189.     }
  190.     My_Receiver.resume();
  191.   }
  192.   delay(DELAY);
  193. }
  194. ///////////////////////////////Loop End///////////////////////////////
  195.  
  196. /**Funtion to check if the lamp should either enter a HIGH mode,
  197.   or revert to NORMAL if already in HIGH. If the sensors report values
  198.   that are higher than 1.1 times the average values, and this has happened
  199.   more than 30 times the last few milliseconds, it will enter HIGH mode.
  200.   TODO: Not very well written, remove hardcoded values, and make it more
  201.   reusable and configurable.  */
  202. void check_high(int avg) {
  203.   if (avg > (song_avg / iter * 1.1))  {
  204.     if (high.times != 0) {
  205.       if (millis() - high.times_start > 200.0) {
  206.         high.times = 0;
  207.         songmode = NORMAL;
  208.       } else {
  209.         high.times_start = millis();
  210.         high.times++;
  211.       }
  212.     } else {
  213.       high.times++;
  214.       high.times_start = millis();
  215.  
  216.     }
  217.   }
  218.   if (high.times > 30 && millis() - high.times_start < 50.0)
  219.   { songmode = HIGH;
  220.     //Serial.println("HIGH");
  221.   }
  222.   else if (millis() - high.times_start > 200) {
  223.     high.times = 0;
  224.     songmode = NORMAL;
  225.     //Serial.println("NORMAL");
  226.  
  227.   }
  228. }
  229.  
  230. //Main function for visualizing
  231. void visualize_music(int specVal, int row_no) {
  232.   int sensor_value, mapped, avg, longavg;
  233.  
  234.   //Actual sensor value
  235.   sensor_value = specVal;
  236.   /*
  237.     //If 0, discard immediately. Probably not right and save CPU.
  238.     if (sensor_value == 0)
  239.     return;
  240.   */
  241.   //Discard readings that deviates too much from the past avg.
  242.   mapped = (float)fscale(minval, maxval, minval, (float)maxval, (float)sensor_value, 2.0);
  243.   avg = compute_average(avgs, AVGLEN);
  244.  
  245.   if (((avg - mapped) > avg * DEV_THRESH)) //|| ((avg - mapped) < -avg*DEV_THRESH))
  246.     return;
  247.  
  248.   //Insert new avg. values
  249.   insert(mapped, avgs, AVGLEN);
  250.   insert(avg, long_avg, LONG_SECTOR);
  251.  
  252.   //Compute the "song average" sensor value
  253.   song_avg += avg;
  254.   iter++;
  255.   if (iter > CYCLES) {
  256.     song_avg = song_avg / iter;
  257.     iter = 1;
  258.   }
  259.  
  260.   longavg = compute_average(long_avg, LONG_SECTOR);
  261.  
  262.   //Check if we enter HIGH mode
  263.   check_high(longavg);
  264.  
  265.   if (songmode == HIGH) {
  266.     fade_scale = 3;
  267.     Color.r = 5;
  268.     Color.g = 3;
  269.     Color.b = -1;
  270.   }
  271.   else if (songmode == NORMAL) {
  272.     fade_scale = 2;
  273.     Color.r = -1;
  274.     Color.b = 2;
  275.     Color.g = 1;
  276.   }
  277.  
  278.   //Decides how many of the LEDs will light up
  279.   curshow = fscale(minval, maxval, 0.0, (float)NUM_LEDS_SINGLE, (float)avg, -1);
  280.  
  281.   /*Set the different leds. Control for too high and too low values.
  282.           Fun thing to try: Dont account for overflow in one direction,
  283.     some interesting light effects appear! */
  284.   for (int i = 0; i < NUM_LEDS_SINGLE; i++)
  285.     //The leds we want to show
  286.     if (i < curshow) {
  287.       if (leds[7 * row_no + i].r + Color.r > 255)
  288.         leds[7 * row_no + i].r = 255;
  289.       else if (leds[7 * row_no + i].r + Color.r < 0)
  290.         leds[7 * row_no + i].r = 0;
  291.       else
  292.         leds[7 * row_no + i].r = leds[7 * row_no + i].r + Color.r;
  293.  
  294.       if (leds[7 * row_no + i].g + Color.g > 255)
  295.         leds[7 * row_no + i].g = 255;
  296.       else if (leds[7 * row_no + i].g + Color.g < 0)
  297.         leds[7 * row_no + i].g = 0;
  298.       else
  299.         leds[7 * row_no + i].g = leds[7 * row_no + i].g + Color.g;
  300.  
  301.       if (leds[7 * row_no + i].b + Color.b > 255)
  302.         leds[7 * row_no + i].b = 255;
  303.       else if (leds[7 * row_no + i].b + Color.b < 0)
  304.         leds[7 * row_no + i].b = 0;
  305.       else
  306.         leds[7 * row_no + i].b = leds[7 * row_no + i].b + Color.b;
  307.  
  308.       //All the other LEDs begin their fading journey to eventual total darkness
  309.     } else {
  310.       leds[7 * row_no + i] = CRGB(leds[7 * row_no + i].r / fade_scale, leds[7 * row_no + i].g / fade_scale, leds[7 * row_no + i].b / fade_scale);
  311.     }
  312.   FastLED.show();
  313. }
  314. //Compute average of a int array, given the starting pointer and the length
  315. int compute_average(int *avgs, int len) {
  316.   int sum = 0;
  317.   for (int i = 0; i < len; i++)
  318.     sum += avgs[i];
  319.  
  320.   return (int)(sum / len);
  321.  
  322. }
  323.  
  324. //Insert a value into an array, and shift it down removing
  325. //the first value if array already full
  326. void insert(int val, int *avgs, int len) {
  327.   for (int i = 0; i < len; i++) {
  328.     if (avgs[i] == -1) {
  329.       avgs[i] = val;
  330.       return;
  331.     }
  332.   }
  333.  
  334.   for (int i = 1; i < len; i++) {
  335.     avgs[i - 1] = avgs[i];
  336.   }
  337.   avgs[len - 1] = val;
  338. }
  339.  
  340. //Function imported from the arduino website.
  341. //Basically map, but with a curve on the scale (can be non-uniform).
  342. float fscale( float originalMin, float originalMax, float newBegin, float
  343.               newEnd, float inputValue, float curve) {
  344.  
  345.   float OriginalRange = 0;
  346.   float NewRange = 0;
  347.   float zeroRefCurVal = 0;
  348.   float normalizedCurVal = 0;
  349.   float rangedValue = 0;
  350.   boolean invFlag = 0;
  351.  
  352.  
  353.   // condition curve parameter
  354.   // limit range
  355.  
  356.   if (curve > 10) curve = 10;
  357.   if (curve < -10) curve = -10;
  358.  
  359.   curve = (curve * -.1) ; // - invert and scale - this seems more intuitive - postive numbers give more weight to high end on output
  360.   curve = pow(10, curve); // convert linear scale into lograthimic exponent for other pow function
  361.  
  362.   // Check for out of range inputValues
  363.   if (inputValue < originalMin) {
  364.     inputValue = originalMin;
  365.   }
  366.   if (inputValue > originalMax) {
  367.     inputValue = originalMax;
  368.   }
  369.  
  370.   // Zero Refference the values
  371.   OriginalRange = originalMax - originalMin;
  372.  
  373.   if (newEnd > newBegin) {
  374.     NewRange = newEnd - newBegin;
  375.   }
  376.   else
  377.   {
  378.     NewRange = newBegin - newEnd;
  379.     invFlag = 1;
  380.   }
  381.  
  382.   zeroRefCurVal = inputValue - originalMin;
  383.   normalizedCurVal  =  zeroRefCurVal / OriginalRange;   // normalize to 0 - 1 float
  384.  
  385.   // Check for originalMin > originalMax  - the math for all other cases i.e. negative numbers seems to work out fine
  386.   if (originalMin > originalMax ) {
  387.     return 0;
  388.   }
  389.  
  390.   if (invFlag == 0) {
  391.     rangedValue =  (pow(normalizedCurVal, curve) * NewRange) + newBegin;
  392.  
  393.   }
  394.   else     // invert the ranges
  395.   {
  396.     rangedValue =  newBegin - (pow(normalizedCurVal, curve) * NewRange);
  397.   }
  398.  
  399.   return rangedValue;
  400. }
  401.  
  402. ///////////////////Matrix Function Definitions///////////////////
  403. void FillLEDsFromPaletteColors( uint8_t colorIndex)
  404. {
  405.   uint8_t brightness = 255;
  406.  
  407.   for ( int i = 0; i < NUM_LEDS; i++) {
  408.     leds[i] = ColorFromPalette( currentPalette, colorIndex, brightness, currentBlending);
  409.     colorIndex += 3;
  410.   }
  411. }
  412.  
  413.  
  414. // There are several different palettes of colors demonstrated here.
  415. //
  416. // FastLED provides several 'preset' palettes: RainbowColors_p, RainbowStripeColors_p,
  417. // OceanColors_p, CloudColors_p, LavaColors_p, ForestColors_p, and PartyColors_p.
  418. //
  419. // Additionally, you can manually define your own color palettes, or you can write
  420. // code that creates color palettes on the fly.  All are shown here.
  421.  
  422. void ChangePalettePeriodically()
  423. {
  424.     uint8_t secondHand = (millis() / 1000) % 60;
  425.     static uint8_t lastSecond = 99;
  426.    
  427.     if( lastSecond != secondHand) {
  428.         lastSecond = secondHand;
  429.         if( secondHand ==  0)  { currentPalette = RainbowColors_p;         currentBlending = LINEARBLEND; }
  430.         if( secondHand == 10)  { currentPalette = RainbowStripeColors_p;   currentBlending = NOBLEND;  }
  431.         if( secondHand == 15)  { currentPalette = RainbowStripeColors_p;   currentBlending = LINEARBLEND; }
  432.         if( secondHand == 20)  { SetupPurpleAndGreenPalette();             currentBlending = LINEARBLEND; }
  433.         if( secondHand == 25)  { SetupTotallyRandomPalette();              currentBlending = LINEARBLEND; }
  434.         if( secondHand == 30)  { SetupBlackAndWhiteStripedPalette();       currentBlending = NOBLEND; }
  435.         if( secondHand == 35)  { SetupBlackAndWhiteStripedPalette();       currentBlending = LINEARBLEND; }
  436.         if( secondHand == 40)  { currentPalette = CloudColors_p;           currentBlending = LINEARBLEND; }
  437.         if( secondHand == 45)  { currentPalette = PartyColors_p;           currentBlending = LINEARBLEND; }
  438.         if( secondHand == 50)  { currentPalette = myRedWhiteBluePalette_p; currentBlending = NOBLEND;  }
  439.         if( secondHand == 55)  { currentPalette = myRedWhiteBluePalette_p; currentBlending = LINEARBLEND; }
  440.     }
  441. }
  442.  
  443. // This function fills the palette with totally random colors.
  444. void SetupTotallyRandomPalette()
  445. {
  446.     for( int i = 0; i < 16; i++) {
  447.         currentPalette[i] = CHSV( random8(), 255, random8());
  448.     }
  449. }
  450.  
  451. // This function sets up a palette of black and white stripes,
  452. // using code.  Since the palette is effectively an array of
  453. // sixteen CRGB colors, the various fill_* functions can be used
  454. // to set them up.
  455. void SetupBlackAndWhiteStripedPalette()
  456. {
  457.     // 'black out' all 16 palette entries...
  458.     fill_solid( currentPalette, 16, CRGB::Black);
  459.     // and set every fourth one to white.
  460.     currentPalette[0] = CRGB::White;
  461.     currentPalette[4] = CRGB::White;
  462.     currentPalette[8] = CRGB::White;
  463.     currentPalette[12] = CRGB::White;
  464.    
  465. }
  466.  
  467. // This function sets up a palette of purple and green stripes.
  468. void SetupPurpleAndGreenPalette()
  469. {
  470.     CRGB purple = CHSV( HUE_PURPLE, 255, 255);
  471.     CRGB green  = CHSV( HUE_GREEN, 255, 255);
  472.     CRGB black  = CRGB::Black;
  473.    
  474.     currentPalette = CRGBPalette16(
  475.                                    green,  green,  black,  black,
  476.                                    purple, purple, black,  black,
  477.                                    green,  green,  black,  black,
  478.                                    purple, purple, black,  black );
  479. }
  480.  
  481.  
  482. // This example shows how to set up a static color palette
  483. // which is stored in PROGMEM (flash), which is almost always more
  484. // plentiful than RAM.  A static PROGMEM palette like this
  485. // takes up 64 bytes of flash.
  486. const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM =
  487. {
  488.     CRGB::Red,
  489.     CRGB::Gray, // 'white' is too bright compared to red and blue
  490.     CRGB::Blue,
  491.     CRGB::Black,
  492.    
  493.     CRGB::Red,
  494.     CRGB::Gray,
  495.     CRGB::Blue,
  496.     CRGB::Black,
  497.    
  498.     CRGB::Red,
  499.     CRGB::Red,
  500.     CRGB::Gray,
  501.     CRGB::Gray,
  502.     CRGB::Blue,
  503.     CRGB::Blue,
  504.     CRGB::Black,
  505.     CRGB::Black
  506. };
  507. /////////////////Matrix Function Definitions End/////////////////
A hozzászólás módosítva: Márc 6, 2021
(#) dB_Thunder hozzászólása Márc 6, 2021 /
 
Ééés akkor most ugorjunk végre a PLATINUM kódjaihoz!!
Elsőnek az alap 7 sávos, a DMS-307 programja. Ezt már próbáltam!!
Ami tetszik: minden sávnak meg lehet adni az erősítését, illetve a "zaját". Ettől függetlenül én valamiért mégis túl zajosnak ítéltem.
Mellékletben a szükséges H file.

  1. //7 BAND SPECTRUM ANALYZER MSGE07
  2. //DESIGN PLATINUM 2019 www.youtube.com/c/PLATINUMKIT
  3. //YOUTUBE VIDEO DIY ACRYLIC PART.1   https://youtu.be/xDKbpwumgF8
  4. //YOUTUBE VIDEO DIY ACRYLIC PART.2
  5. //YOUTUBE VIDEO DIY INFINITY MIRROR  https://youtu.be/j2-0d9xBDJk
  6. //THIS IS NOT FOR SALE ONLY FOR HOBBIES.
  7. //WE SHARE TO ADD A KNOWLEDGE SCIENCE.
  8.  
  9.  
  10. #include <math.h>
  11. #include <Adafruit_NeoPixel.h>
  12. #include "MSGEQ7V1.h"
  13. Timer t;                                  
  14. #define Acolor A0
  15. #define Scolor A6
  16. #define Pcolor A7
  17. #define MAX_BRIGHTNESS 255
  18. #define MIN_BRIGHTNESS 10
  19. const int brightnessInPin = A2;
  20. int led = 5;
  21. unsigned long x;
  22. unsigned long y = 0;
  23. const byte analogPin          = A1;
  24. const byte strobePin          = 3;
  25. const byte resetPin           = 2;
  26. const byte dataPin            = 4;
  27. const byte numBand            = 20;  //number of LEDs
  28. const byte numTop             = 0;
  29. const int noise[]             = {20, 20, 20, 20, 20, 20, 20};
  30. const float gain[]            = {2.05,  2.05,  2.05, 2.05,  2.05,   2.05,   2.05}; //Frequency GAIN
  31.                   //Frequency =  63Hz, 160Hz, 400Hz, 1kHz, 2.5kHz, 6.25kHz, 16kHz
  32. const unsigned long dlay      = 30;
  33.  
  34. Adafruit_NeoPixel strip = Adafruit_NeoPixel(numBand*7, dataPin, NEO_GRB + NEO_KHZ800);
  35. enum audio {
  36.   MONO,
  37.   RIGHT,
  38.   LEFT };
  39. int spectrumReadR;
  40. int spectrumReadL;
  41. int audio = MONO;
  42. int mag = 0;
  43. int numON = 0;
  44. float fl_mag = 0.0;
  45. int k;
  46. int a;  
  47. int s;  
  48. int peakArray[7];
  49. byte
  50.   peak = 0,
  51.   dotCount = 0;
  52.  
  53. void setup() {
  54.   Serial.begin(9600);
  55.   pinMode(resetPin, OUTPUT);
  56.   pinMode(strobePin, OUTPUT);
  57.   pinMode(dataPin, OUTPUT);
  58.   strip.begin();
  59.   strip.show();
  60.   digitalWrite(resetPin,HIGH);
  61.   delayMicroseconds(5);
  62.   digitalWrite(strobePin,HIGH);
  63.   delayMicroseconds(50);
  64.   digitalWrite(strobePin,LOW);
  65.   delayMicroseconds(50);
  66.   digitalWrite(resetPin,LOW);
  67.   delayMicroseconds(5);              
  68.   digitalWrite(strobePin,HIGH);
  69.   delayMicroseconds(100);
  70.   t.every(80,peakLower);
  71. }
  72. void loop() {
  73. CReSet();
  74. x = millis();
  75. }
  76. int dimH = 0;
  77. int p = 0;
  78. const long interval = 1;
  79. void CReSet(){
  80. if(x - y >= interval){
  81. y = x;
  82. dimH = map(p, 0, 4000, 0, 255);
  83. analogWrite(led, dimH);                                
  84. if(p >= 4000){ p = 0; }
  85. else { p = p + 1; }
  86. }
  87.     int mappedValue = map(analogRead(brightnessInPin), 0, 1023, 0, 255);
  88.     strip.setBrightness(constrain(mappedValue, MIN_BRIGHTNESS, MAX_BRIGHTNESS));
  89.     a = analogRead(Acolor);
  90.     a = map(a, 0, 1023, 0,400);
  91.     s = analogRead(Scolor);
  92.     s = map(s, 0, 1023, 35,1500);
  93.     k = analogRead(Pcolor);
  94.     k = map(k, 0, 1023, 0,750);
  95.     for(byte band = 1; band <= 7; band++) {
  96.     digitalWrite(strobePin, LOW);
  97.     delayMicroseconds(40);
  98.     spectrumReadL = analogRead(analogPin);
  99.     digitalWrite(strobePin, HIGH);  
  100.     mag = (spectrumReadR + spectrumReadL) / 2;
  101.     mag = max(0, (mag - noise[band-1]));
  102.     fl_mag = gain[band-1] * float(mag);
  103.     numON = map(fl_mag, 0, 1024, 1, numBand+1);
  104.     anyBand(band);    
  105.     if(peakArray[band-1]==0) strip.setPixelColor(peakArray[band-1] + numBand*(band-1), strip.Color(0,0,0));
  106.     else strip.setPixelColor(peakArray[band-1] + numBand*(band-1), Wheel(map(10,0,numBand-0,k,255)));
  107.     t.update();
  108.   }
  109.   strip.show();
  110.   delay(dlay);
  111. }
  112.  
  113. void readBand(byte band) {
  114.   for(byte band = 1; band <= 7; band++) {
  115.     digitalWrite(strobePin, LOW);
  116.     delayMicroseconds(40);
  117.     spectrumReadL = analogRead(analogPin);
  118.     digitalWrite(strobePin, HIGH);
  119.     mag = (spectrumReadR + spectrumReadL) / 2;
  120.     mag = max(0, (mag - noise[band-1]));
  121.     fl_mag = gain[band-1] * float(mag);
  122.     numON = map(fl_mag, 0, 1024, 1, numBand+1);
  123.     anyBand(band);
  124.   }
  125. }
  126.  
  127. void anyBand(byte band) {
  128.   for(byte i = 0; i < numBand; i++){
  129.     if(i < (numON - numTop - 1)){
  130.       strip.setPixelColor(i + numBand*(band-1), Wheel(map(i,0,numBand-s,a,255)));
  131.     }
  132.     else if(i >= numON){
  133.       strip.setPixelColor(i + numBand*(band-1), strip.Color(0,0,0));
  134.     }
  135.     else{
  136.       if(i > peakArray[band-1]) peakArray[band-1] = i;
  137.     }
  138.   }
  139. }
  140.  
  141. void peakLower() {
  142.   for(byte i = 0; i < 7; i++) {
  143.     if(peakArray[i] > 1) peakArray[i]--;
  144.     else continue;
  145.   }
  146. }
  147.  
  148. uint32_t Wheel(byte WheelPos) {
  149.   WheelPos = 255 - WheelPos;
  150.   if(WheelPos < 85) {
  151.     return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  152.   }
  153.   if(WheelPos < 170) {
  154.     WheelPos -= 85;
  155.     return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  156.   }
  157.   WheelPos -= 170;
  158.   return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  159. }

MSGEQ7V1.h
    
(#) dB_Thunder válasza dB_Thunder hozzászólására (») Márc 6, 2021 /
 
Most pedig a 14 sávos kódja! Legtöbb utánépítő erre a kódra hivatkozik, de a videókban látható színösszeállításoknak látványosabb részét ez sem tudja! Gyanúsan vissza butított progi, vannak benne olyan sorok amiket nem használ! A videók alatti leírásban pl. ezt a programot nem is lehet elérni, csak a előlapi embléma úszó szivárnyányos programját!
A zajt jobban kezeli. Én is most ezen a kódon dolgozom. Megpróbálom értelmezni, kommenteket fordítom, kiegészítem. Már átírtam, hogy 24 pixel magas oszlopot is tudjon.

sketch_may11a.ino:
  1. //   Project: 14 Band Spectrum Analyzer using WS2812B/SK6812
  2. //   Target Platform: Arduino Mega2560 or Mega2560 PRO MINI
  3. //   The original code has been modified by PLATINUM to allow a scalable platform with many more bands.
  4. //   It is not possible to run modified code on a UNO,NANO or PRO MINI. due to memory limitations.
  5. //   The library Si5351mcu is being utilized for programming masterclock IC frequencies.
  6. //   Special thanks to Pavel Milanes for his outstanding work. https://github.com/pavelmc/Si5351mcu
  7. //   Analog reading of MSGEQ7 IC1 and IC2 use pin A0 and A1.
  8. //   Clock pin from MSGEQ7 IC1 and IC2 to Si5351mcu board clock 0 and 1
  9. //   Si5351mcu SCL and SDA use pin 20 and 21
  10. //   See the Schematic Diagram for more info
  11. //   Programmed and tested by PLATINUM
  12. //   Version 1.0
  13. //***************************************************************************************************
  14. #include <avr/wdt.h>
  15. #include <Adafruit_NeoPixel.h>
  16. #include <si5351mcu.h>    //Si5351mcu library
  17. Si5351mcu Si;             //Si5351mcu Board
  18. #define PULSE_PIN     13
  19. #define NOISE         20 //was 50
  20. #define ROWS          20  //num of row MAX=20
  21. #define COLUMNS       14  //num of column
  22. #define DATA_PIN      9   //led data pin
  23. #define STROBE_PIN    6   //MSGEQ7 strobe pin
  24. #define RESET_PIN     7   //MSGEQ7 reset pin
  25. #define NUMPIXELS    ROWS * COLUMNS
  26. int Intensity = 20;
  27. int pauzeTop = 1;
  28. int Sensitivity = 1;
  29. int mode = 0;
  30. //bool modechange=false;
  31. bool Showmode = false;
  32. char barRed = 0, barGreen = 255, barBlue = 100;
  33. char topRed = 205, topGreen = 50, topBlue = 0;
  34. char randomRed = 0, randomGreen = 0, randomBlue = 0;
  35. long lastDebounceTime = 0;  // the last time the output pin was toggled
  36. long debounceDelay = 200;    // the debounce time; increase if the output flickers
  37. long LastDoNothingTime = 0;
  38. long DoNothingTime = 60000;
  39. /*
  40.    Mode 0 = green column with red top holding
  41.    Mode 1 = blue column with red top holding
  42.    Mode 2 =
  43.    Mode 3 =
  44.    Mode 4 =
  45.    Mode 5 =
  46.    Mode 6 =
  47.    Mode 7 =
  48.    Mode 8 =
  49.    Mode 9 =
  50.    Mode 10 =
  51. */
  52.  
  53.  
  54. struct Point {
  55.   char x, y;
  56.   char  r, g, b;
  57.   bool active;
  58. };
  59. struct TopPoint {
  60.   int position;
  61.   int peakpause;
  62. };
  63. Point spectrum[ROWS][COLUMNS];
  64. TopPoint peakhold[COLUMNS];
  65. int spectrumValue[COLUMNS];
  66. long int counter = 0;
  67. int long pwmpulse = 0;
  68. bool toggle = false;
  69. int long time_change = 0;
  70. int effect = 0;
  71. Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, DATA_PIN, NEO_GRB + NEO_KHZ800);
  72.  
  73. void setup()
  74. {
  75.   Si.init(25000000L);
  76.   Si.setFreq(0, 104570);
  77.   Si.setFreq(1, 166280);
  78.   Si.setPower(0, SIOUT_8mA);
  79.   Si.setPower(1, SIOUT_8mA);
  80.   Si.enable(0);
  81.   Si.enable(1);
  82.   pinMode      (STROBE_PIN,    OUTPUT);
  83.   pinMode      (RESET_PIN,     OUTPUT);
  84.   pinMode      (DATA_PIN,      OUTPUT);
  85.   pinMode      (PULSE_PIN,     OUTPUT);
  86.   digitalWrite(PULSE_PIN, HIGH);
  87.   delay(100);
  88.   digitalWrite(PULSE_PIN, LOW);
  89.   delay(100);
  90.   digitalWrite(PULSE_PIN, HIGH);
  91.   delay(100);
  92.   digitalWrite(PULSE_PIN, LOW);
  93.   delay(100);
  94.   digitalWrite(PULSE_PIN, HIGH);
  95.   delay(100);
  96.   pixels.setBrightness(20); //set Brightness
  97.  
  98.   pixels.begin();
  99.   pixels.show();
  100.   pinMode      (STROBE_PIN, OUTPUT);
  101.   pinMode      (RESET_PIN,  OUTPUT);
  102.   digitalWrite (RESET_PIN,  LOW);
  103.   digitalWrite (STROBE_PIN, LOW);
  104.   delay        (1);
  105.   digitalWrite (RESET_PIN,  HIGH);
  106.   delay        (1);
  107.   digitalWrite (RESET_PIN,  LOW);
  108.   digitalWrite (STROBE_PIN, HIGH);
  109.   delay        (1);
  110.   pinMode(59, INPUT_PULLUP); // switch
  111.   randomSeed(analogRead(0));
  112. }
  113. void loop()
  114. {
  115.   counter++;
  116.   clearspectrum();
  117.   if (millis() - pwmpulse > 3000) {
  118.     toggle = !toggle;
  119.     digitalWrite(PULSE_PIN, toggle);
  120.     pwmpulse = millis();
  121.   }
  122.   digitalWrite(RESET_PIN, HIGH);
  123.   delayMicroseconds(3000);
  124.   digitalWrite(RESET_PIN, LOW);
  125.   for (int i = 0; i < COLUMNS; i++) {
  126.  
  127.     digitalWrite(STROBE_PIN, LOW);
  128.     delayMicroseconds(1000);
  129.     spectrumValue[i] = analogRead(0)-NOISE;
  130.     if (spectrumValue[i] < 120)spectrumValue[i] = 0;
  131.  
  132.     spectrumValue[i] = constrain(spectrumValue[i], 0, Sensitivity);
  133.     spectrumValue[i] = map(spectrumValue[i], 0, Sensitivity, 0, ROWS); i++; //1023
  134.     spectrumValue[i] = analogRead(1)-NOISE;
  135.     if (spectrumValue[i] < 120)spectrumValue[i] = 0;
  136.        
  137.     spectrumValue[i] = constrain(spectrumValue[i], 0, Sensitivity);
  138.     spectrumValue[i] = map(spectrumValue[i], 0, Sensitivity, 0, ROWS);
  139.     if (spectrumValue[i] > 6)LastDoNothingTime = millis();
  140.     digitalWrite(STROBE_PIN, HIGH);
  141.   }
  142.  
  143.   // Read de set intensity
  144.   Intensity = analogRead(2);
  145.   Intensity = map(Intensity, 0, 1023, 150, 0);
  146.   pixels.setBrightness(Intensity); //set Brightness
  147.  
  148.   // read pauzetijd van de top
  149.   pauzeTop = analogRead(3);
  150.   pauzeTop = map(pauzeTop, 0, 1023, 100, 0);
  151.  
  152.   //read the sensitivity
  153.   Sensitivity = analogRead(4);
  154.   Sensitivity = map(Sensitivity, 0, 1023, 120, 1023);
  155.  
  156.   // read switch
  157.   if (digitalRead(59) == LOW) {
  158.     if ( (millis() - lastDebounceTime) > debounceDelay) {
  159.       mode++;
  160.       if (mode == 8)mode = 0;
  161.       ChangeMod();
  162.       lastDebounceTime = millis();
  163.     }
  164.   }
  165.  
  166.   // do nothing timer....showdown if no input for long time
  167.   if ((millis() - LastDoNothingTime) > DoNothingTime) {
  168.     //mode++;
  169.     //     if (mode == 8)mode = 0;
  170.     //   ChangeMod();
  171.     // Showmode=true;
  172.     rainbow(25);
  173.     LastDoNothingTime = millis();
  174.  
  175.   }
  176.   //if(Showmode==true)StartDemo();
  177.   // enter demo mode because long time no input
  178.  
  179.   for (int j = 0; j < COLUMNS; j++) {
  180.     // randomRed=random(255);
  181.     //randomGreen=random(255);
  182.     //randomBlue=random(255);
  183.     for (int i = 0; i < spectrumValue[j]; i++) {
  184.  
  185.       if (mode == 6) { // random colors om all tiles
  186.  
  187.         spectrum[i][j].active = 1;
  188.         spectrum[i][j].r = random(255);          //COLUMN Color red
  189.         spectrum[i][j].g = random(255);        //COLUMN Color green
  190.         spectrum[i][j].b = random(255);          //COLUMN Color blue
  191.  
  192.       }
  193.       else if (mode == 4) { // random color per column
  194.         spectrum[i][j].active = 1;
  195.  
  196.         switch (j) {
  197.           case 0:
  198.             spectrum[i][j].r = 0;          //COLUMN Color red
  199.             spectrum[i][j].g = 0;        //COLUMN Color green
  200.             spectrum[i][j].b = 255;          //COLUMN Color blue
  201.             break;
  202.           case 1:
  203.             spectrum[i][j].r = 0;          //COLUMN Color red
  204.             spectrum[i][j].g = 255;        //COLUMN Color green
  205.             spectrum[i][j].b = 0;          //COLUMN Color blue
  206.             break;
  207.           case 2:
  208.             spectrum[i][j].r = 0;          //COLUMN Color red
  209.             spectrum[i][j].g = 255;        //COLUMN Color green
  210.             spectrum[i][j].b = 255;          //COLUMN Color blue
  211.             break;
  212.           case 3:
  213.             spectrum[i][j].r = 255;          //COLUMN Color red
  214.             spectrum[i][j].g = 0;        //COLUMN Color green
  215.             spectrum[i][j].b = 0;          //COLUMN Color blue
  216.             break;
  217.           case 4:
  218.             spectrum[i][j].r = 255;          //COLUMN Color red
  219.             spectrum[i][j].g = 0;        //COLUMN Color green
  220.             spectrum[i][j].b = 255;          //COLUMN Color blue
  221.             break;
  222.           case 5:
  223.             spectrum[i][j].r = 255;          //COLUMN Color red
  224.             spectrum[i][j].g = 255;        //COLUMN Color green
  225.             spectrum[i][j].b = 0;          //COLUMN Color blue
  226.             break;
  227.           case 6:
  228.             spectrum[i][j].r = 255;          //COLUMN Color red
  229.             spectrum[i][j].g = 80;        //COLUMN Color green
  230.             spectrum[i][j].b = 205;          //COLUMN Color blue
  231.             break;
  232.           case 7:
  233.             spectrum[i][j].r = 50;          //COLUMN Color red
  234.             spectrum[i][j].g = 100;        //COLUMN Color green
  235.             spectrum[i][j].b = 255;          //COLUMN Color blue
  236.             break;
  237.           case 8:
  238.             spectrum[i][j].r = 255;          //COLUMN Color red
  239.             spectrum[i][j].g = 255;        //COLUMN Color green
  240.             spectrum[i][j].b = 0;          //COLUMN Color blue
  241.             break;
  242.           case 9:
  243.             spectrum[i][j].r = 215;          //COLUMN Color red
  244.             spectrum[i][j].g = 40;        //COLUMN Color green
  245.             spectrum[i][j].b = 120;          //COLUMN Color blue
  246.             break;
  247.           case 10:
  248.             spectrum[i][j].r = 120;          //COLUMN Color red
  249.             spectrum[i][j].g = 100;        //COLUMN Color green
  250.             spectrum[i][j].b = 40;          //COLUMN Color blue
  251.             break;
  252.           case 11:
  253.             spectrum[i][j].r = 50;          //COLUMN Color red
  254.             spectrum[i][j].g = 10;        //COLUMN Color green
  255.             spectrum[i][j].b = 90;          //COLUMN Color blue
  256.             break;
  257.           case 12:
  258.             spectrum[i][j].r = 90;          //COLUMN Color red
  259.             spectrum[i][j].g = 150;        //COLUMN Color green
  260.             spectrum[i][j].b = 55;          //COLUMN Color blue
  261.             break;
  262.           case 13:
  263.             spectrum[i][j].r = 95;          //COLUMN Color red
  264.             spectrum[i][j].g = 155;        //COLUMN Color green
  265.             spectrum[i][j].b = 25;          //COLUMN Color blue
  266.             break;
  267.         }
  268.  
  269.  
  270.       }
  271.       else {
  272.         spectrum[i][j].active = 1;
  273.         spectrum[i][j].r = barRed;          //COLUMN Color red
  274.         spectrum[i][j].g = barGreen;        //COLUMN Color green
  275.         spectrum[i][j].b = barBlue;          //COLUMN Color blue
  276.       }
  277.     }
  278.  
  279.  
  280.     if (spectrumValue[j] - 1 > peakhold[j].position)
  281.     {
  282.       spectrum[spectrumValue[j] - 1][j].r = 0;
  283.       spectrum[spectrumValue[j] - 1][j].g = 0;
  284.       spectrum[spectrumValue[j] - 1][j].b = 0;
  285.       peakhold[j].position = spectrumValue[j] - 1;
  286.       peakhold[j].peakpause = pauzeTop;// 1; //set peakpause
  287.     }
  288.     else
  289.     {
  290.       spectrum[peakhold[j].position][j].active = 1;
  291.       spectrum[peakhold[j].position][j].r = topRed;  //Peak Color red
  292.       spectrum[peakhold[j].position][j].g = topGreen;  //Peak Color green
  293.       spectrum[peakhold[j].position][j].b = topBlue;    //Peak Color blue
  294.     }
  295.  
  296.  
  297.   }
  298.  
  299.   flushMatrix();
  300.   if (counter % 3 == 0)topSinking(); //peak delay
  301.  
  302.  
  303.  
  304. }
  305. void topSinking()
  306. {
  307.   for (int j = 0; j < ROWS; j++)
  308.   {
  309.     if (peakhold[j].position > 0 && peakhold[j].peakpause <= 0) peakhold[j].position--;
  310.     else if (peakhold[j].peakpause > 0) peakhold[j].peakpause--;
  311.   }
  312. }
  313. void clearspectrum()
  314. {
  315.   for (int i = 0; i < ROWS; i++)
  316.   {
  317.     for (int j = 0; j < COLUMNS; j++)
  318.     {
  319.       spectrum[i][j].active = false;
  320.     }
  321.   }
  322. }
  323. void flushMatrix()
  324. {
  325.   for (int j = 0; j < COLUMNS; j++)
  326.   {
  327.  
  328.  
  329.  
  330.     for (int i = 0; i < ROWS; i++)
  331.     {
  332.       if (spectrum[i][j].active)
  333.       {
  334.         pixels.setPixelColor(j * ROWS + i, pixels.Color(
  335.                                spectrum[i][j].r,
  336.                                spectrum[i][j].g,
  337.                                spectrum[i][j].b));
  338.       }
  339.       else
  340.       {
  341.         pixels.setPixelColor( j * ROWS + i, 0, 0, 0);
  342.       }
  343.     }
  344.  
  345.   }
  346.   pixels.show();
  347. }
  348. void ChangeMod()
  349. {
  350.   switch (mode) {
  351.     case 0:
  352.       barRed = 0;
  353.       barGreen = 255;
  354.       barBlue = 0;
  355.  
  356.       topRed = 255;
  357.       topGreen = 0;
  358.       topBlue = 0;
  359.       break;
  360.  
  361.     case 1:
  362.       barRed = 0;
  363.       barGreen = 0;
  364.       barBlue = 255;
  365.  
  366.       topRed = 0;
  367.       topGreen = 255;
  368.       topBlue = 0;
  369.       break;
  370.  
  371.     case 2:
  372.       barRed = 255;
  373.       barGreen = 0;
  374.       barBlue = 0;
  375.  
  376.       topRed = 0;
  377.       topGreen = 0;
  378.       topBlue = 255;
  379.       break;
  380.  
  381.     case 3:
  382.       barRed = 255;
  383.       barGreen = 0;
  384.       barBlue = 0;
  385.  
  386.       topRed = 255;
  387.       topGreen = 0;
  388.       topBlue = 0;
  389.       break;
  390.  
  391.     case 4:
  392.       //each column diff color implemented elsewhere
  393.       break;
  394.  
  395.     case 5:
  396.       // rainbow accross
  397.       break;
  398.     case 6:
  399.       // random collors implemented elsewhere
  400.       break;
  401.   }
  402.  
  403. }
  404. void StartDemo()
  405. {
  406.   // rainbow should start
  407.   rainbow(25);
  408. }
  409.  
  410.  
  411. void rainbow(int wait) {
  412.   pixels.setBrightness(20);
  413.  
  414.   for (long firstPixelHue = 0; firstPixelHue < 5 * 65536; firstPixelHue += 256) {
  415.         if (millis() - pwmpulse > 3000) {
  416.     toggle = !toggle;
  417.     digitalWrite(PULSE_PIN, toggle);
  418.     pwmpulse = millis();
  419.   }
  420.      
  421.       digitalWrite(RESET_PIN, HIGH);
  422.   delayMicroseconds(3000);
  423.   digitalWrite(RESET_PIN, LOW);
  424.  
  425.        delayMicroseconds(1000);
  426.     digitalWrite(STROBE_PIN, HIGH);
  427.     delayMicroseconds(1000);
  428.     digitalWrite(STROBE_PIN, LOW);
  429.     delayMicroseconds(1000);
  430.     digitalWrite(STROBE_PIN, HIGH);
  431.     delayMicroseconds(1000);
  432.     digitalWrite(STROBE_PIN, LOW);
  433.   //  delayMicroseconds(1000);
  434.   //  digitalWrite(STROBE_PIN, HIGH);
  435.    // delayMicroseconds(1000);
  436.     //digitalWrite(STROBE_PIN, LOW);
  437.     spectrumValue[1] = analogRead(1);
  438.    
  439.    
  440.     spectrumValue[1] = constrain(spectrumValue[1], 0, Sensitivity);
  441.     spectrumValue[1] = map(spectrumValue[1], 0, Sensitivity, 0, ROWS);
  442. if (spectrumValue[1] >6){return;}
  443.     digitalWrite(STROBE_PIN, HIGH);
  444.  
  445.    
  446.    
  447.    
  448.    
  449.    
  450.    
  451.     for (int i = 0; i < 280; i++) { // For each pixel in strip...
  452.      
  453.       /*
  454.        * First check to see if there is activity on one of the bands. If true then reset
  455.        *
  456.  
  457.        */
  458.  // if (millis() - pwmpulse > 3000) {
  459.  //   toggle = !toggle;
  460.  //   digitalWrite(PULSE_PIN, toggle);
  461.  //   pwmpulse = millis();
  462. //  }
  463.  
  464.  
  465.  
  466.       //***
  467.       int pixelHue = firstPixelHue + (i * 65536L / 280);
  468.       pixels.setPixelColor(i, pixels.gamma32(pixels.ColorHSV(pixelHue)));
  469.    }
  470.     pixels.show(); // Update strip with new contents
  471.    // delay(wait);  // Pause for a moment
  472.   }
  473. }
A hozzászólás módosítva: Márc 6, 2021
(#) dB_Thunder válasza dB_Thunder hozzászólására (») Márc 6, 2021 /
 
Egy utánépítő szépen részletező lapja: Bővebben: Link
(#) sznyeg hozzászólása Márc 8, 2021 /
 
Igazság szerint a professzionális audió megfejtésekben ( hangosításokon, stúdió megfejtésekben is ) csak 1/3 oktávos (32 sávos) felbontást használnak, mert sűrűbbnek nincs értelme, ehhez igazodnak a frekvenciasávok.
Ehhez igazodik természetesen az equalizerek sávleosztása is, pont azért, mert egyébként az állandó jóságú szűrők átfednék egymást és az egyik sáv állítása beleszólna a mellette levőbe.

De persze, lehet sűrűbbet is csinálni, látványos lesz.
A hozzászólás módosítva: Márc 8, 2021
(#) dB_Thunder válasza sznyeg hozzászólására (») Márc 8, 2021 /
 
Számomra is egy kicsit elmebeteg a Generatorlabs 42sávja!
Az már 6 db MSGEQ7, és rengeteg led!! A legnagyobb problémát abban látom, hogy az MSGEQ7 belső szűrőinek a jósága, sávszélessége annyi amennyi, de némileg függ az órajelétől! Ha csökken az órajel, csökken a jóság. És mi pont csökkentjük az órajelet, hogy a megfelelő irányba elhangoljuk a szűrőket.
Szóval a végén hiába lesz egy halom sávunk, mert a szűrők sávszélessége nem elegendően szűk(alacsony jóság), hogy rendesen szétválassza a frekvenciákat. Hiszen az ic-t 7 sávra találták ki, ahhoz optimalizálták a szűrők sávszélességét.
Gyakorlatilag egyetlen frekire is több oszlop fog valamilyen arányban jelezni.

Tesztjeim alapján úgy látom, hogy a 14 sáv még egész jól működik. Talán a 21 sáv is még elfogadható lesz, az pont kihasználná a Si5351A 3 órajel kimenetét!

Ha tervezek ehhez nyákot, szerintem az 3db MSGEQ7 ic-nek csinálok helyet!! Aztán azt vagy beülteti, használja, az utánépítő, vagy nem! Programot meg hozzá lehet igazítani.
(#) dB_Thunder válasza dB_Thunder hozzászólására (») Márc 8, 2021 /
 
A másik probléma a sok sávval, és hozzá tartozó rengeteg leddel, hogy ki is kell számolni, ki is kell íratni azokat! Ez mind-mind idő, és a végén már nem mondható "real time"-nak az egész.

Már a mostani 14 sávost sem mondanám túl gyors kijelzésűnek! Lehet látni némi késedelmet.
Arra vagyok most kíváncsi, hogy ezt a 336 ledet (eredetileg 280)mennyi idő végigcímezni!!
Emiatt már elgondolkoztam egy "duál processzoros" megoldáson is. Minden msgeq-t külön proc olvas, külön számol, és a hozzá tartozó oszlopokat önállóan írja. Csak meg kellene oldani, hogy mind2 azonos kijelzési üzemmódba legyen.
Sajnos jelen pill. ehhez sovány a programozási tudásom.
(#) benjami válasza dB_Thunder hozzászólására (») Márc 8, 2021 /
 
Ha nem elég az MSGEQ7 által nyújtott 7 sáv nem volna egyszerűbb elfelejteni ezeket a tokokat és megcsinálni az egészet 1-2 műveleti erősítővel meg egy 32 bites kontrollerrel (mondjuk FFT-t alkalmazva) ?
(#) dB_Thunder válasza benjami hozzászólására (») Márc 9, 2021 /
 
FFT-vel mennyire lehet megfelelő jóságú szűrés csinálni, és azt mennyi idő alatt számolja ki a proci?? Illetve mennyibe kerül egy olyan proci ami ezt tudja?

Van egyébként FFT-t használó projek ugyanilyen led szalaggal!

Nekem nem az egyszerűség, olcsóság a fontos, hanem a gyorsaság !
Régen is utáltam a legtöbb kivezérlésjelzőt mert késet! Sima, direkt, analóg, kicsi időtaggal, az jó volt.

Most olvasom a NeoPixel lib leírását a kiíratás sebességéről:
Idézet:
„about 30 microseconds per RGB pixel”

Tehát a bő 330 led kiíratása 0,01 másodperc, és ilyenkor nem számol animációt, nem olvas be jelszintet...

Azon is gondolkozom, hogy tudnám megmérni a program ciklus idejét! Mert a mostani sebessége is határeset a számomra, gyorsítani kellene...

Kicsit más:
Abban sem vagyok biztos, hogy az ilyen MSGEQ ic-ben van valós 7db kapcsolt kapacitás szűrő!!
Néztem árakat az ilyen fajta szűrő ic-nek, horror!! És az csak 1 sáv lenne...
Tehát az is elképzelhető, hogy fizikailag csak egyetlen szűrőtag van az ic-ben, és azt hangolják nagyon gyorsan végig a teljes spektrumon.

Idő-idő-idő...
(#) benjami válasza dB_Thunder hozzászólására (») Márc 9, 2021 /
 
Minden attól függ, hány pontos FFT-t használsz. Nagyobb felbontás -> több processzoridő, nagyobb késleltetés (már csak az miatt is, mert meg kell várni amíg előáll az a minta mennyiség).
A másik módszer, ha nem FFT-t használsz, hanem FIR szűrőt. Annak nincs késleltetése. Viszont annyi FIR szűrőt kell használnod, ahány sávot szeretnél. Minél több sávot szeretnél, annál meredekebb szűrőt kell csinálnod hozzá, a meredekebb szűrő meg több együtthatót igényel.
Itt egy FIR szűrő tervező oldal.
Egy 100 lábú stm32f407-t tartalmazó board most 10$ körül van (+2$ egy olcsó st-link programozó hozzá). Ez a chip 168MHz max frekvencián tud futni, hardveres lebegőpontos egységet is tartalmaz. Ha ez kevés, akkor 20$ körül van 400MHz-es chip-et tartalmazó board is (stm32h743).
(#) Oszipapa hozzászólása Márc 9, 2021 /
 
Sziasztok.
Ez a projekt engem is érdekelne Ha lesz már müködö darab, (nekem elég lenne a 14 sávos is),esetleg
ha publikus lenne a nyák terv,(akár kész ,megvehetö nyákkal), kapcsolási rajz,esetleg felprogramozott
vezérlövel, azt nagyon
megköszönném.( a programozás nem az erösségem ).
(#) dB_Thunder válasza Oszipapa hozzászólására (») Márc 9, 2021 /
 
Bármit tudunk!

Van más pár videóm a sajátomról, hogy az hogy áll, mert én, ugyan más projektekkel párhuzamosan, kb fél éve foglalkozok ezzel!
Most ez össze van dugdosva egy próba panelon.

Szóval, itt egy videó a sajátomról, egyenlő csak egy panelre ragasztottam fel az 5m szalagot.Hang nincs!
(#) dB_Thunder válasza benjami hozzászólására (») Márc 9, 2021 /
 
Huh..

Nem vagyok ennyire otthon a programozós, jelfeldolgozós témakörben!
PLC-kel szo-szo elboldogulok, C programozás nagyon alapjai még mennek, aztán vége is a tudásomnak
Hátulgombolósoknak való szinten kifejtenéd ezeket a FIR szűrőket??
Azt látom, hogy ez is program, de mit adunk neki, és mit kapunk? És ha program, csak kell neki némi futási idő...

Kezdjük ott, hogy van 1 audió analóg szignálunk!
(#) Oszipapa válasza dB_Thunder hozzászólására (») Márc 10, 2021 /
 
Szia. Ez eddig hibátlannak néz ki. Esetleg publikus lenne a rajza, panelje, stb? Esetleg készitesz e megrendelésre?
(#) dB_Thunder válasza Oszipapa hozzászólására (») Márc 10, 2021 /
 
Ennek teljesen publikus a rajza, a panelja, még a programja is!

7 sávos építési leírása


Nálam ez most így néz ki:
A hozzászólás módosítva: Márc 10, 2021
(#) Peter65 válasza dB_Thunder hozzászólására (») Márc 13, 2021 /
 
Szerintem Fourier analízissel viszonylag egyszerű szűrőt készíteni, és a jósága is könnyen kézben tartható, azonban ilyen széles spektrumú vizsgálat esetében nem biztos, hogy nyerő lesz. A számítási torzítások és speciális ablakolási technikák elkerülése érdekében az egyes spektrumok meghatározásánál célszerű a szűrési frekvencia periódus idejének egész számú többszöröse hosszúságú ablakokat használni, ami miatt a szélesebb spektrumoknál viszonylag kevés a választás. Hogy érthetőbb legyek, legyen egy f frekvencia, és a hozzá tartozó periódusidő T hosszú. Ha az ablak szélessége 1T, akkor a spektrum szélessége 0,5f-től 1,5f-ig tart. DFT-vel ennél rosszabb jóság nem érhető el. Ha 2T periódus az ablak szélessége, akkor a spektrum 0,75f-től 1,25f-ig tart. A spektrum szélessége df=1/T összefüggéssel számolható.
Ezek alapján a Fourier szűrést akkor célszerű választanod, ha a spektrumok frekvenciái oktávonként vagy féloktávonként vannak. A 20-20000Hz-es tartomány nagyjából 10 oktávra bontható, azaz ha 10 vagy 20 spektrumot szeretnél, szerintem akkor érdemes ebben az irányban tájékozódnod.
(#) flaci76 válasza dB_Thunder hozzászólására (») Márc 13, 2021 /
 
IIR szűrővel érdemes megcsinálni és fixpontos számábrázolással. Egy Blue Pill board 32 bites STM32F103-al pl. 10 sávot 48kHz audio mintavételi freki mellett könnyedén lekezel, valós időben, minden bejövő mintát elkapva és így is csak kb 50% CPU időt vesz el a szűrők működtetése ADC IRQ rutinban. Mivel nem bufferel, hanem minden érkező mintával számol, így a sávszűrő rendszer gyors, késés mentes és semmit nem hagy ki a streamből, ellenben az FFT-sekkel. Elrontani gyakorlatilag csak a kijelzés FPS-el lehet. Ezt Arduinoban csináltam, Keil-el ugyanezen a board-on 2x7 sávos sztereó megoldást is csináltam, de nyilván ez megoldható 1x14 sáv változatban is, sőt kb olyan 16 sáv az ami véleményem szertin a plafon egy ilyen boarddal. Ezek a példányok OLED kijelzőre dolgoznak, kicsit felhúzva az OLED órajelét, így 135Hz FPS-el renderelve. Nagyon szép sima mozgásokat és gyors képet ad. Tudok feltenni forráskódot mindkettőről, de át kell írni őket ha LED-szalagra kell dolgoznia.
A frekvenciák és a szűrőjóságok is megadhatók, de nem futásidőben. Egy python kódot írtam a szűrők együtthatóinak kiszámítására, ezel konstansok lesznek a forráskódban.
A kódok amúgy sajnos kicsit kaotikusak, még nem volt igazán időm letisztítani, meg rendesen felkommentelni.
(#) dB_Thunder válasza flaci76 hozzászólására (») Márc 17, 2021 /
 
Helló!

Nézegettem ezeket a digi filtereket, ITT elég érthetően leírják! Ez mellett még elolvastam pár leírást.
Most már én is nagyjából megemésztettem a működésüket! Tetszik, hogy igen nagy meredekségű szűrőt is tudunk csinálni, alkatrészhalom nélkül!

Később biztos megnézzük a teljes digitális jelfeldolgozás! De addig nekem nagyon, de nagyon sokat kell tanulnom még programozni!

Csináltam jelgenerátorral egy "ellenőrzést", videó a lentebbi linken. Szerintem a 21 sáv még egy értelmes felbontás lehet! De azért látszik az analóg szűrés hibája, a szomszédos sávok áthallása!

Másik apró hiba, a kijelzés lineáris! Lehalkítom, nagyon hamar nem mutat semmit.

Kicsit elmélkedtem, kísérleteztem a fizikai kivitelezéssel: Plexi hasábok ideális méretei, rögzítésük, a fény eloszlása a hasábban.
Vágtam 25db 50x60mm hasábokat 10es anyagból.
Elsőre zavart, hogy a plexi közepén nagyon erős a led, de a "gyáriban" is. Fúrtam egy kb 5ös furatot a led elé, az sokat javított fényeloszláson, viszont a fényerő nem túl sok a plexin keresztül! Lehet duplán kellene szalagozni....

PROJEKT VIDEÓK
A hozzászólás módosítva: Márc 17, 2021
(#) dB_Thunder válasza flaci76 hozzászólására (») Márc 17, 2021 /
 
Szeretnék kérni egy kis kezdő lökést ezekhez az ARM cumókhoz! Pl milyen fejlesztői környezetben érdemes használni? Van erősebb lap mint a Blue Pill??
(#) flaci76 válasza dB_Thunder hozzászólására (») Márc 18, 2021 /
 
Én annó digit szűrőkből írtam a szakdogám. De még így is csak a felszínt kapargatom már ami az elméleti dolgokat illeti. Azért valóban sok jó szűrőtervező cucc van, pl. a Matlab Fdatools, vagy a python nyelv scipy pluginja. Azt azért jó kézzel tapintani, amikor egy digit szűrő működni kezd pl. egy mikrovezérlőben

Ez a MSGEQ7 IC jó cucc, régebben már én is szemeztem vele, csak elfogadható beszerzési forrást nem találtam rá. A frekik eltologatása az órajellel tényleg jó ötlet, lényegében az összes freki arányosan fog eltolódni vele. Eredetileg 2,5-szeres ugrások vannak, így pl. egy gyök(2,5)=1,58-szoros óra emelés vagy csökkentés pont a meglévő frekik közé lövi be az új spektrumvonalakat. (köbgyök 2,5-el lehetne harmadolni) Viszont ha túl gyakoriak lesznek a frekik, akkor már mosott lesz a frekiszelektivitás, mert a szűrők meredekségét is növelni kellene, vagy a jóság megemelésével hozni létre keskeny sávátvitelt, de ezt már nem lehet állítani az IC-n. A lecsengés vezérléssel úgylátom nem lesz gond,az nem az órajeltől függ, hanem minden kiolvasáskor csökken 10%-ot. Nekem amúgy tetszik, mert így tényleg a legkisebb képességű Arduino board is elég lehet.
Talán még az játszhat, hogy ilyen MSGEQ7 szerű funkciójú dolgot csinálni egy STM32 BluePill-ből, csak nincs D/A konvertere, SPI vagy I2C-n lehetne lekérdezhetni róla az értékeket, vagy PWM, de arra meg aluláteresztő kell, bonyolódik. Visszatérve a szűrőkre, azért el lehet játszani vele. Gondolj csak bele, hogy van egy 72MHz-es órajellel rendelkező procid, és szeretnél egy 48kHz-es mintavételezést, ahol minden bejövő ADC mintára rá akarsz ugrani. Mondjuk nem akarsz DMA-t, mert akkor az már késik, azaz tényleg minden ADC mintára lefut egy megszakítási rutin. Két mintavétel között 72M/48k=1500 cpu órajel ketyeg el, jól meg kell gondolni, hogy ebbe mit, mennyit, és hogyan írsz be. Pl. ha float vagy double számokkal kezdesz szűrőt számolni akkor már ki is estél, hacsak nincs hardveres float támogatás. Én integerre tettem minden számítást, szűrőegyütthatót, sok helyen az osztás helyett bit shift-et használok stb, hogy spóroljak azon az 1500 órán, amibe úgy kell beleférni, hogy jusson a főprogramnak is cpu idő.

A logaritmikus kijelzést meg lehet szerintem oldani, át lehet számítani log értékekre, de a kb 20dB átfogás nem lesz nagyobb, kb ennyit tud az IC. BluePill-nél ez kb 30dB, mert kb ott jön az ADC zajszintje magasfrekin, mivel nincs a board-on szétválasztva az analog és digitális táp és föld, így nagyon zajos az ADC-je.

BluePill:

Jó cucc, nekem bevált. kb 2000Ft darabja (kvázi olcsóbb, mint maga a mikrovezérlője!), ár/érték arányban igen jó. Hasonló/jobb 32 biteseket 8-10kHUF-tól mérnek.
Elindulni többféle úton is lehet vele, egyik az Arduino. Én az STM32duino alaplapi csomagot töltöttem le, ill. azt használom hozzá. Van az STM microelecktronics féle mondhatni "hivatalos" csomagja, de nekem azzal voltak problémáim. Kell hozzá STlink V2 programozó is, az a biztos, de ez se drága cucc. Lehet fejleszteni még STM32cube vagy Keil környezetben is és ehhez nagyon jó magyar nyelvű cucc is van Bővebben: Link Azért azt halkan megjegyezném, hogy ugyanaz a funkcionalitású programom Arduinoban 26kB, Keilben 4.7kB-ra fordult le, ill. a futási sebesség is valahogy mindig jobb Keil-ben.

Amivel most babrálok (sajnos eddig nem túl sok sikerrel) az az, hogy i2s ADC/DAC konvertereket kössek valahogy össze ilyen-olyan board-okkal. Leszedtem egy SB Audigy4-ről egy UDA1361T 96kHz/24bit stereo ADC ic-t és próbapanelon el is indítottam master i2s-ként. Működik is, logikai analizátorral sikerült dekódolni is a kimenetet, adtam a bemenetére szinusz jelet stb. Még így is kb 80-90dB jel/zaj viszonyt produkált. Messze sokkal jobb, mint a mikrokontrollerbe integrált ADC, ezzel akár 40-60dB átfogású kijelzéseket is lehetne csinálni, sőt konkrétan precíz audió méréseket lehetne lezavarni vele. (pl hangszóró impedancia és T/S mérőt mikrokontroller alapon, saját kijelzéssel, user interface-el, önállóan és PC-vel is működőt, az igen jól hangzana)

ui: a sávelválasztás nálam sem a legjobb, sima 6-6dB/okt, csak a szűrő Q-ja fel van egy kicsit húzva. Hasonló, mint sok analog műveletierősítős változat, igazából azokból vettem a szűrőkaraktert.
Sweep video
A hozzászólás módosítva: Márc 18, 2021
(#) dB_Thunder válasza flaci76 hozzászólására (») Márc 19, 2021 /
 
Mérnökként, akinek még oktatták is ezt, könnyű!
Én csak egyszerű drótos vagyok! Minden infót, okosságot magamnak kell felcsipegetni.
Néztem az adatlapodat, meg a honlapodon a munkásságaidat!
Nagyon hasonló az érdeklődési körünk, Te egy szinttel komolyabban műveled. Túl messze sem lakunk egymástól.

Arduinóhoz való bővítményt hirtelen nem találtam, feladtam. A Keil-t letöltöttem majd ránézek.

Találtam egy ilyet hogy NUCLEO, ezen van már programozó rész is. Lehet fejlesztéshez jobb lenne. Az kérdéses számomra, hogy csak saját magát képes programozni vagy rávehető másik eszköz programozására is?
Az elkészült eszközbe, a lehető legegyszerűbb, és csak a szükséges alkatrészeket tartalmazó modul elég.

Most már azt is tudom miért zajos a játék szkópom (DSO-SHELL)! Próbáltam tenni is ellene de arra jutottam hogy tokon belül van a baj. Nem kellett volna 5mV/DIV méréshatárt csinálni rá a kitalálójának...
(#) dB_Thunder hozzászólása Ápr 10, 2021 /
 
Közben, pár hete Platinum kijött a 21 sávos verziójával!
Már 32bites procival operál, de a hangsávokat még mindig msgeq7-tel dolgozza fel.
Kapott pár animációt, a zene szünet idejére is!
Persze a teljes programot most se tárja elénk, akinek kell fizethet csak a vezérlőért kb 60 ezret!
21 band Spectrum

Én közben vettem 2 öreg, de 64 bites Nucleo lapot, lassan ideér még egy adag led szalag, és poti. Van pár gondolatom amit ki akarok próbálni. Illetve még mindig gondolkozom, hogy milyen, és mekkora legyen a végső fizikai megvalósulása! Ez a fekete hátterű nekem nem elég légies, Viszont a talpa tetszik! De valahova el kell rakni az elektronikát is! Azon is gondolkozom hogy kicsit old-school kinézet okán fából csinálom meg a talpat, hogy menjen a Orion hangfalaimhoz
(#) dB_Thunder hozzászólása Ápr 13, 2021 / 1
 
Csak 1 változót cseréltem ki másikra:
Szivárványoszlop


Innentől csak "recepteket" kell megírni!
Következő: »»   1 / 2
Bejelentkezés

Belépés

Hirdetés
Lapoda.hu     XDT.hu     HEStore.hu
Az oldalon sütiket használunk a helyes működéshez. Bővebb információt az adatvédelmi szabályzatban olvashatsz. Megértettem