// LED #include #define PIN 2 Adafruit_NeoPixel strip = Adafruit_NeoPixel(4, PIN, NEO_GRB + NEO_KHZ800); //MIC const int inputPin = A2; const int inputWindow = 5; unsigned int inputSample; unsigned int diff; unsigned int is; float proc; unsigned int R; unsigned int G; unsigned int B; unsigned int x; unsigned int y; unsigned int z; unsigned int w; unsigned int X = 0; unsigned int revR = 0; unsigned int revG; unsigned int revB; unsigned int H; unsigned int t; unsigned int sample; unsigned long cs; unsigned long I = 1; void setup() { strip.begin(); strip.show(); // Initialize all pixels to 'off' pinMode(inputPin, INPUT); Serial.begin(9600); } void loop() { strip.show(); unsigned int inputMax = 0; unsigned int inputMin = 1000; for (unsigned int i = 0; i < inputWindow; i++) { inputSample = analogRead(inputPin); if (inputSample < inputMin){ inputMin = inputSample; } if (inputSample > inputMax){ inputMax = inputSample; } diff = inputMax - inputMin; Serial.println (diff); } //LED //R = 0; //B = 0; //G = 0; //dristy /* inputSample = analogRead(inputPin); proc = (inputMax/100); if (inputSample > (inputMax*0.95)){ R = 255; G = 0; B = 0; } if (inputSample > (inputMax*0.954)){ R = 255; G = 82; B = 0; } if (inputSample > (inputMax*0.958)){ R = 255; G = 123; B = 0; } if (inputSample > (inputMax*0.962)){ R = 255; G = 224; B = 0; } if (inputSample > (inputMax*0.966)){ R = 255; G = 82; B = 0; } if (inputSample > (inputMax*0.97)){ R = 255; G = 255; B = 3; } if (inputSample > (inputMax*0.974)){ R = 28; G = 225; B = 0; } if (inputSample > (inputMax*0.978)){ R = 0; G = 255; B = 134; } if (inputSample > (inputMax*0.99)){ R = 0; G = 49; B = 255; } */ if (diff > 17) { R = 200; G = G-50; B = B - 50; } cs = millis(); if (cs != I) { cs == I; H++; t++; } if (H == 2) { if (revR == 1) { R = R - 6; if (R <= 5){ R = 0; revR = 0;} } else { R = R + 6; if (R >= 255){ R = 255; revR = 1;} } } if (H == 4) { if (revG == 1) { G = G - 4; if (G <= 5){ G = 0; revG = 0;} } else { G = G + 4; if (G >= 255){ G = 255; revG = 1;} } } if (H == 6) { if (revB == 1) { B = B - 2; if (B <= 5){ B = 0; revB = 0;} } else { B = B + 2; if (B >= 255){ B = 255; revB = 1;} } H = 0; } if (t==50) { X++; if (X > 3) X = 0; t=0; } strip.setPixelColor(0, x, 0, 0); strip.setPixelColor(1, y, 0, 0); strip.setPixelColor(2, z, 0, 0); strip.setPixelColor(3, w, 0, 0); strip.setPixelColor(X, R, G, B); strip.show(); }