Sorry in German. But quite selfexplanatory. Controlling a led chain with a mini microphone and spectral analysis. Easier than what it seems
Really neat, do you care to add more details. For example, would you be providing the code and components used?
My code is still a mess, comments half German half English but yes I will provide it once cleaned up. It was my first project and I was too eager to finish as to be tidy. Will find time next weekend.
The components are a Nano, any IR receiver, any 38 kHz IR Remote, W2812 Pixels chain, and microphone was a MAX 9814 for 3€, everything on a bread board. A USB scope is a nice to have but reading the analog input and sending it over 2MB/s to the Serial Plotter of the ARduino IDE is a sufficient alternative and actually easier to trigger. My scope has no Ac coupling and the output is already offset by 1.25 V to be nicely in the middle of the ADC range.
It will take my weekend to document myself. Be patient, and if you are not, it was really easy and you can start yourselves.
Here is the code, I mostly removed the German from the comments and the variable names. It is my first C program in twenty years and shows the heavy hand of a FORTRAN programmer. It won´t win in any code metric but it works.
Ready for cut and past, not for being read here on G+. Cut and paste it your Arduino IDE and press CTL T it will clean up identation.
Have fun.
No schematics yet. A close up fotograph will have to suffice for the time being
MIC
Connect A0 of your Arduino Nano or Uno to OUT of the MAX9418 mic, connect the mic to VCC and ground. Connect Ar to ground if you do not want gain automatic of the preamp in there. Keep the input labeld gain floating for maximum gain.
Connect the Neopixels Ground to the Arduino Ground, but you probably dont connect the 5 V to VIN . 5V is not enough for VIN on the Arduino and probably an affordable powersupply will go down under heavy load to less than 4 which is definitely not enough for the Arduino but keeps the WS2812 up and running. You may try at your own risk conect to the Arduino 5v to the strip 5v which is supplied to the Arduino through its own power supply. Connect the data line of the neopixel to pin 2. If you are obedient put a 200-400 Ohm resistor between the Neopixel in and the outputpin 2 of the Arduino.
Connect the OUT pin of the IR receiver to Input 10 and the other to respectively GND and VCC.
Dont run above 50 updates per second if you want to stay in control via IR,
Find out about the remote control commanda looking at the code.
If you have another Remote Control just press the buttons and find out in the serial monitor what each code is. FFFF is just a key repeat.
ir_9 gets you in disco mode, ir white to reading lamp mode in white.
In disco mode say something and switch on some music. You might have to callibrate the threshold and range for varianz, hp_varianz, and lp_varianz look for “calibrate here” in the code
And above all have fun.
// NeoPixel Ring simple sketch (c) 2013 Shae Erisson
// released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library
#include <Adafruit_NeoPixel.h>
// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1
#define PIN 2
// How many NeoPixels are attached to the Arduino?
#define NUM_LEDS 144
// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parameter-<s>see the strandtest</s>
<s>// example for more information on possible values.</s>
<s>Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);</s>
<s>// Fernbedienung</s>
#include<s> <IRremote.h></s>
<s>//#include <IRremoteInt.h></s>
#define<s> irPin 10</s>
<s>IRrecv irrecv(irPin); //initialise object for IR reception</s>
<s>decode_results results;</s>
<s>// Abbrevation for key on the IR controller</s>
<s>// look at the console which code your IR produces with which key and choose the function you want to associate with it.</s>
#define<s> ir_brighter 0xA857 //</s>
#define<s> ir_darker 0xE01F</s>
#define<s> ir_faster 0x02fd</s>
#define<s> ir_slower 0x22dd</s>
#define<s> ir_wider 0xA25D</s>
#define<s> ir_narrower 0xE21D</s>
#define<s> ir_white 0x906f</s>
#define<s> ir_panic 0x629D</s>
#define<s> ir_pause 0xC23D</s>
#define<s> ir_fireworks 0x9867</s>
#define<s> ir_0 0x6897</s>
#define<s> ir_1 0x30cf</s>
#define<s> ir_2 0x18e7</s>
#define<s> ir_3 0x7a85</s>
#define<s> ir_4 0x10ef</s>
#define<s> ir_5 0x38c7</s>
#define<s> ir_6 0x5aa5</s>
#define<s> ir_7 0x42bd</s>
#define<s> ir_8 0x4ab5</s>
#define<s> ir_9 0x52ad</s>
#define<s> ir_store 0xb04f</s>
<s>byte wave[128]; // store 0 .. pi of sin wave in 8 bit which is all we need.</s>
<s>// yea, I know 0..pi/2 is sufficient I will do the mirroring when I need the extra 64 byte</s>
<s>// Bad FORTRAN habit to communicate global variable, but it work</s>
<s>static volatile int oldcommand = 0, oszilloskop = 1;</s>
<s>byte sound_control = false;</s>
<s>// 10 different Settings storable in EEPROM</s>
<s>struct settings</s>
<s>{ long updateFrequency , zeit, waveFrequency, speed, width, white, brightness;</s>
<s>} s[1] = {{50, 0, 500, 10, 10, 0, 64}, // just to have a good startin point on a blank Arduino</s>
<s> /</s><s><b>{50, 0, 500, 0, 1, 0, 64}, {50, 0, 500, 0, 1, 0, 64}, {50, 0, 500, 0, 1, 0, 64},</b></s>
<s><b> {50, 0, 500, 0, 1, 0, 64}, {50, 0, 500, 0, 1, 0, 64}, {50, 0, 500, 0, 1, 0, 64}, {50, 0, 500, 0, 1, 0, 64},</b></s>
<s><b> {50, 0, 500, 0, 1, 0, 64}, {50, 0, 500, 0, 1, 0, 64} */</b></s>
<s><b>};</b></s>
#include<s><b> <EEPROM.h></b></s>
#include<s><b> <Math.h> // used for log maths to get dB, one day I will look for a faster integer implementation/table</b></s>
<s><b>// Play with the Microphone</b></s>
#define<s><b> MikrofonPin 2</b></s>
#define<s><b> samples 60 // is when the estimator for the student and the Gaussian variance are good enough the same</b></s>
<s><b>const int analogInPin = MikrofonPin;</b></s>
<s><b>volatile float lp_varianz, varianz, hp_varianz;</b></s>
<s><b>void mikro() {</b></s>
<s><b> // local transient variable for calculating the energies in the three bands that is variance.</b></s>
<s><b> // which is mean of the squares minus square of the mean. I never remember which one, do abs if you dont believe me</b></s>
<s><b> // I assure you it´s gotta be positive.</b></s>
<s><b> // Variabeln zum Berechen der Gesamt, Hoch, Tief Varianz= Energie</b></s>
<s><b> long sum, sum2; // sum of samples and sum of squared samples</b></s>
<s><b> float mean;</b></s>
<s><b> long lp_sum, lp_sum2; // same for low frequency which just takes the average of two adjacent samples,</b></s>
<s><b> float lp_mean;</b></s>
<s><b> long hp_sum, hp_sum2; // same for low frequency which just takes the differenc of two adjacent samples,</b></s>
<s><b> // really a modest high frequency filter with lots of ringing but too lazy so far tó implement an FFT</b></s>
<s><b> float hp_mean;</b></s>
<s><b> long sensorValue, oldSensorValue, i;</b></s>
<s><b> long differenz, tsum; // sum German, guess what differenz could be</b></s>
<s><b> unsigned int red, blue, green;</b></s>
<s><b> unsigned long v;</b></s>
<s><b> unsigned long db_meter;</b></s>
<s><b> sum = sum2 = lp_sum = lp_sum2 = hp_sum = hp_sum2 = 0; // clear all sums</b></s>
<s><b> oldSensorValue = analogRead(analogInPin); // get one more for low and high frequence for allowing for average and differentiation</b></s>
<s><b> for ( i = 0; i < samples; i++) // we take 30 samples at 10 kHz, to see frequencies up to 5 kHz</b></s>
<s><b> { // I am old I do not hear above</b></s>
<s><b> // We dont see anything below 150 Hert though as wie only sample for 15 ms</b></s>
<s><b> sensorValue = analogRead(analogInPin); // read the Mic, on the analog pin it is really so simple</b></s>
<s><b> sum = sum + sensorValue;</b></s>
<s><b> sum2 = sum2 + (sensorValue * sensorValue);</b></s>
<s><b> differenz = oldSensorValue - sensorValue; // dirty differentiation for high frequencies</b></s>
<s><b> hp_sum = hp_sum + differenz;</b></s>
<s><b> hp_sum2 = hp_sum2 + differenz * differenz;</b></s>
<s><b> tsum = (oldSensorValue + sensorValue) / 2 ; // averagin´ for frequencies below half o</b></s>
<s><b> lp_sum = lp_sum + tsum;</b></s>
<s><b> lp_sum2 = lp_sum2 + (tsum * tsum);</b></s>
<s><b> /</b></s><s> Serial.print("oldSens ");</s>
<s> Serial.print(oldSensorValue); Serial.print(" ");</s>
<s> Serial.print("newSens ");</s>
<s> Serial.print(sensorValue); Serial.print(" ");</s>
<s> Serial.print("Summe ");</s>
<s> Serial.print(tsum); Serial.print(" ");</s>
<s> Serial.print("lp_sum ");</s>
<s> Serial.print(lp_sum); Serial.print(" ");</s>
<s> Serial.print("lp_sum2 ");</s>
<s> Serial.print(lp_sum2);</s>
<s> Serial.println(" ");</s>
<s> </s><s><b>/</b></s>
<s><b> oldSensorValue = sensorValue;</b></s>
<s><b> delayMicroseconds(50);</b></s>
<s><b> };</b></s>
<s><b> mean = sum / samples; // all frequencies</b></s>
<s><b> // we are engineer so we go logarithmic, which we do all the time for whatever reason. Just do show we studied</b></s>
<s><b> varianz = 10 * log(sum2 / samples - mean * mean );</b></s>
<s><b> lp_mean = lp_sum / samples; // just the low ones</b></s>
<s><b> lp_varianz = 10 * log((lp_sum2 / samples - lp_mean * lp_mean ) * 2);</b></s>
<s><b> hp_mean = hp_sum / samples;</b></s>
<s><b> hp_varianz = 10 * log(hp_sum2 / samples - hp_mean * hp_mean );</b></s>
<s><b> // send them to the serial monitor for calibration the poor man´s scope</b></s>
<s><b> if (oszilloskop)</b></s>
<s><b> { // switch on to see the energie function in the Serial Plotter</b></s>
<s><b> Serial.print(lp_varianz); Serial.print(" ");</b></s>
<s><b> Serial.print(hp_varianz); Serial.print(" ");</b></s>
<s><b> Serial.println(varianz);</b></s>
<s><b> }</b></s>
<s><b> // Lösche den Balken</b></s>
<s><b> for (int i = 0; i < NUM_LEDS; i++)</b></s>
<s><b> pixels.setPixelColor(i, pixels.Color(0, 0, 0));</b></s>
<s><b> // roter Equalizer Balken in rot von rechts für hohe tiefe</b></s>
<s><b> db_meter = (constrain(lp_varianz, 70., 100.) - 70) / 30. * NUM_LEDS ;</b></s>
<s><b> for (int i = 0; i < db_meter; i++)</b></s>
<s><b> pixels.setPixelColor(i, pixels.Color(round(150 * (db_meter - i) / NUM_LEDS), 0, 0));</b></s>
<s><b> // blueer Equalizer Balken in blue von links für hohe Frequenzen lösche den Rotanteil nicht</b></s>
<s><b> db_meter = (constrain(hp_varianz, 70., 100.) - 70) / 30. * NUM_LEDS ;</b></s>
<s><b> for (int i = NUM_LEDS - 1; i > NUM_LEDS - db_meter; i-</b></s><b>)</b>
<b> { unsigned long v;</b>
<b> unsigned red, green, blue;</b>
<b> v = pixels.getPixelColor(i);</b>
<b> red = ((v >> 16) & 0xFF);</b>
<b> green = (v >> 8) & 0xFF;</b>
<b> blue = v & 0xff;</b>
<b> pixels.setPixelColor(i, pixels.Color(red, green, round(40 * i / NUM_LEDS)));</b>
<b> }</b>
<b> // grüner Equalizer Balken in blue von mite für alle Frequenzen, lösche den Rotanteil und blue nicht</b>
<b> db_meter = (constrain(varianz, 70., 100.) - 70) / 30. * NUM_LEDS ;</b>
<b> // Serial.print(varianz); Serial.print(" "); Serial.println(db_meter);</b>
<b> /</b> Serial.print("Grün DbMeter von ");
Serial.print(db_meter);
Serial.print( db_meter/2);
Serial.print( " bis");
Serial.println( NUM_LEDS - db_meter/2); #
<b>/</b>
<b> for (int i = NUM_LEDS / 2 - db_meter ; i < NUM_LEDS / 2 + db_meter; i++)</b>
<b> { unsigned long v;</b>
<b> unsigned red, green, blue;</b>
<b> v = pixels.getPixelColor(i);</b>
<b> red = ((v >> 16) & 0xFF);</b>
<b> green = (v >> 8) & 0xFF;</b>
<b> blue = v & 0xff;</b>
<b> pixels.setPixelColor(i, pixels.Color(red, round(80 - 80 * abs(NUM_LEDS / 2 - i ) / NUM_LEDS), blue));</b>
<b> }</b>
<b> /</b>
for (int i = 0; i < NUM_LEDS; i++)
{
long red, green, blue;
float red_scale, green_scale, blue_scale;
v = pixels.getPixelColor(i);
red = ((v >> 16) & 0xFF);
green = (v >> 8) & 0xFF;
blue = (v) & 0xFF;
red_scale=green_scale= blue_scale= (constrain(lp_varianz, 65., 100.) - 65) / 35.;
// green_scale = (constrain(varianz, 65., 100.) - 65) / 35.;
// blue_scale = (constrain(hp_varianz, 65., 100.) - 65) / 35.;
Serial.print( 255*red_scale); Serial.print(" ");
Serial.print( 255*green_scale); Serial.print(" ");
Serial.println(255*blue_scale);
red = (long)(red * red_scale);
green = (long)(green * green_scale);
blue = (long)(blue * blue_scale);
pixels.setPixelColor(i, pixels.Color(red, green, blue));
};
<b>/</b>
<b>}</b>
<b>void init_wave()</b>
<b>{</b>
<b> int i;</b>
<b> for (i = 0; i < 128; i++)</b>
<b> {</b>
<b> wave[i] = ( sin(2.*PI * (float)i / 256.) * 127.5);</b>
<b> }</b>
<b>}</b>
<b>int sin_wave(unsigned char arg)</b>
<b>{</b>
<b> if (arg < 128) return wave[arg];</b>
<b> return (- wave[arg - 128]);</b>
<b>}</b>
<b>void setup() {</b>
<b> Serial.begin(2000000);</b>
<b> pixels.begin(); // This initializes the NeoPixel library.</b>
<b> pinMode(irPin, INPUT); //set the IR receiver pint.</b>
<b> irrecv.enableIRIn(); // activate it</b>
<b> init_wave(); // precalculate the wave forms to avoid sinus floating point during operation</b>
<b>}</b>
<b>byte fireworks = 0;</b>
<b>unsigned long fwk_cnt = 0;</b>
<b>void fireworks_routine()</b>
<b>{</b>
<b> int red_head, green_head, blue_head, red, green, blue;</b>
<b> float red_ampl, green_ampl, blue_ampl;</b>
<b> unsigned long v;</b>
<b> float scale = 1.0;</b>
<b> // Serial.println ("fireworks Shot" );</b>
<b> for (int i = 0; i < NUM_LEDS; i++) { //dämpfe voriges Muster</b>
<b> unsigned int red, blue, green;</b>
<b> unsigned long v;</b>
<b> // v = (unsigned long)leds[i];</b>
<b> v = pixels.getPixelColor(i);</b>
<b> red = (v >> 16) & 0xFF;</b>
<b> green = (v >> 8) & 0xFF;</b>
<b> blue = (v) & 0xFF;</b>
<b> red = red * s[0].width / 101; green = green * s[0].width / 101; blue = blue * s[0].width / 101;</b>
<b> pixels.setPixelColor(i, pixels.Color(red, green, blue));</b>
<b> };</b>
<b> fwk_cnt += s[0].speed;</b>
<b> red_head = (fwk_cnt / 10) % NUM_LEDS;</b>
<b> green_head = NUM_LEDS - (((fwk_cnt) / 15) - 30) % NUM_LEDS;</b>
<b> blue_head = ((fwk_cnt) / 20 - 80) % (NUM_LEDS * 2);</b>
<b> if (blue_head > NUM_LEDS) blue_head = NUM_LEDS - (blue_head - NUM_LEDS);</b>
<b> for (int j = 0; j < s[0].width; j++)</b>
<b> {</b>
<b> /</b> if (j == 0) {
red_ampl = (float)(fwk_cnt % 10) / 10.<b>250. * s[0].brightness;</b>
<b> green_ampl = (float)(fwk_cnt % 15) / 15.*250. * s[0].brightness;</b>
<b> blue_ampl = (float)(fwk_cnt % 20) / 20.*250. * s[0].brightness;</b>
<b> } else</b>/
{
red_ampl = green_ampl = blue_ampl = (s[0].brightness * scale);
};
v = pixels.getPixelColor((green_head + j) % NUM_LEDS); red = (v >> 16) & 0xFF; green = (v >> 8) & 0xFF; blue = (v) & 0xFF;
pixels.setPixelColor((green_head + j) % NUM_LEDS, pixels.Color( red, green_ampl, blue));
v = pixels.getPixelColor((blue_head - j) % NUM_LEDS); red = (v >> 16) & 0xFF; green = (v >> 8) & 0xFF; blue = (v) & 0xFF;
pixels.setPixelColor((blue_head - j) % NUM_LEDS, pixels.Color(red , green , blue_ampl));
v = pixels.getPixelColor((red_head - j) % NUM_LEDS); red = (v >> 16) & 0xFF; green = (v >> 8) & 0xFF; blue = (v) & 0xFF;
pixels.setPixelColor((red_head - j) % NUM_LEDS, pixels.Color(red_ampl, green , blue ));
scale <b>= 0.90;</b>
<b> }</b>
<b>}</b>
<b>void loop() {</b>
<b> unsigned int i;</b>
<b> int IRdigitKey;</b>
<b> unsigned char red, blue, green;</b>
<b> unsigned long phaseR, phaseG, phaseB;</b>
<b> unsigned long v;</b>
<b> s[0].zeit = s[0].zeit + (1000 / s[0].updateFrequency) * s[0].speed;</b>
<b> /</b> Serial.print(" Zeit ");
Serial.print(s[0].zeit);
Serial.print(" Speed ");
Serial.println(s[0].speed);
<b>/</b>
<b> //Fernbedienung einlesen</b>
<b> if (irrecv.decode(&results)) { // when something was read</b>
<b> unsigned int value = results.value;</b>
<b> irrecv.resume(); // allow next value to be read / reenable interrupts</b>
<b> Serial.println(value, HEX);</b>
<b> if (value == 0xffff) { // repeat key</b>
<b> value = oldcommand;</b>
<b> };</b>
<b> switch (value & 0xffff) {</b>
<b> case ir_panic: // frighten the kids</b>
<b> for (int j = 800; j > 10; j = j * 9 / 10) { // exponentially faster flashes</b>
<b> // reset memory / not leds themselves</b>
<b> for (int i = 0; i < NUM_LEDS; i++) pixels.setPixelColor(i, pixels.Color(0, 0, 0));</b>
<b> // FastLED.show(); // Adafruit is smaller.</b>
<b> pixels.show(); // This sends the updated pixel color to the hardware.</b>
<b> delay(j); // wait a while</b>
<b> for (int i = 0; i < NUM_LEDS; i++) pixels.setPixelColor(i, pixels.Color(200, 200, 200)); // Moderately bright white flash color.</b>
<b> // FastLED.show();</b>
<b> pixels.show(); // This sends the updated pixel color to the hardware.</b>
<b> delay(3);</b>
<b> }</b>
<b> oldcommand = 0; // don´t panic once more</b>
<b> break;</b>
<b> case ir_white: // switch back and for between reading mode and other modes such as wave and fireworks and sound detection</b>
<b> s[0].white = !s[0].white;</b>
<b> oldcommand = 0; // don´t accept repeats</b>
<b> break;</b>
<b> case ir_wider: // breiter</b>
<b> case ir_narrower:</b>
<b> s[0].width += ((value == ir_wider) ? -1 : 1); // make waveforms wider or narrower</b>
<b> s[0].width = constrain(s[0].width, 1, 100); // keep in between 1 and 100</b>
<b> oldcommand = value;</b>
<b> break;</b>
<b> case ir_brighter:</b>
<b> case ir_darker:</b>
<b> s[0].brightness += ((value == ir_brighter) ? 5 : -5); // increase decrease brightness in coarser steps still some 50</b>
<b> s[0].brightness = constrain(s[0].brightness, 0, 160); // don´t overstretch powersupply</b>
<b> oldcommand = value;</b>
<b> break;</b>
<b> case ir_faster:</b>
<b> case ir_slower:</b>
<b> case ir_pause:</b>
<b> // Serial.println("Schneller");</b>
<b> if (value == ir_pause) s[0].speed = 0; // stop and freeze wave animation at the present point</b>
<b> else {</b>
<b> s[0].speed += ((value == ir_faster) ? 2 : -2); // controlle wave propagation speed</b>
<b> s[0].speed = constrain(s[0].speed, -60, 60); // within the reasonable</b>
<b> // Serial.println(speed);</b>
<b> }</b>
<b> oldcommand = value;</b>
<b> break;</b>
<b> case ir_0: //irgend eine IRdigitKey?</b>
<b> case ir_1: case ir_2: case ir_3: case ir_4:</b>
<b> case ir_5: case ir_6: case ir_7: case ir_8: /</b> case ir_9: <b>/</b>
<b> switch (value) // welche?</b>
<b> {</b>
<b> case ir_0:</b>
<b> IRdigitKey = 0; break;</b>
<b> case ir_1:</b>
<b> IRdigitKey = 1; break;</b>
<b> case ir_2:</b>
<b> IRdigitKey = 2; break;</b>
<b> case ir_3:</b>
<b> IRdigitKey = 3; break;</b>
<b> case ir_4:</b>
<b> IRdigitKey = 4; break;</b>
<b> case ir_5:</b>
<b> IRdigitKey = 5; break;</b>
<b> case ir_6:</b>
<b> IRdigitKey = 6; break;</b>
<b> case ir_7:</b>
<b> IRdigitKey = 7; break;</b>
<b> case ir_8:</b>
<b> IRdigitKey = 8; break;</b>
<b> /</b> case ir_9:
IRdigitKey = 9; break; <b>/</b>
<b> }</b>
<b> Serial.print("Nummerntaste ");</b>
<b> Serial.println(IRdigitKey);</b>
<b> if (oldcommand == ir_store) // store current seetting in EPROM with IR_STORE and a digit 1..9</b>
<b> {</b>
<b> uint8_t *source_addr, *dest_addr, cnt;</b>
<b> Serial.print("Speichere aktuelle Einstellung in Speicher"); Serial.println(IRdigitKey);</b>
<b> // s[IRdigitKey] = s[0];</b>
<b> for (source_addr = (char</b>)&s[0], dest_addr = sizeof(s[0]) * IRdigitKey, cnt;
cnt < sizeof(s[0]); source_addr++, dest_addr++, cnt++)
{
EEPROM.write(dest_addr, <b>source_addr);</b>
<b> Serial.print("Writing " ); Serial.print ((uint8_t)*source_addr, HEX);</b>
<b> Serial.print(" To "); Serial.println((long)dest_addr, HEX);</b>
<b> }</b>
<b> }</b>
<b> else // recall the settings from the EEPROM</b>
<b> {</b>
<b> uint8_t *source_addr, *dest_addr, cnt;</b>
<b> Serial.print("Lese Einstellung aus Speicher"); Serial.println(IRdigitKey);</b>
<b> // s[0] = s[IRdigitKey];</b>
<b> for (dest_addr = (char</b>)&s[0], source_addr = sizeof(s[0]) * IRdigitKey, cnt;
cnt < sizeof(s[0]); source_addr++, dest_addr++, cnt++)
{
*dest_addr = EEPROM.read(source_addr);
Serial.print("Read " ); Serial.print ((uint8_t)*dest_addr, HEX);
Serial.print(" from "); Serial.println((long)source_addr, HEX);
}
}
oldcommand = 0; //nicht wiederholen
break;
case ir_store:
oldcommand = ir_store;
break;
case ir_fireworks:
if (fireworks) {
Serial.println("fireworks off");
fireworks = 0;
} else {
Serial.println("fireworks on");
fireworks = 1;
};
oldcommand = 0;
break;
case ir_9:
sound_control = !sound_control;
oszilloskop = !oszilloskop;
oldcommand = 0; // do not fast repeat
break;
default:
oldcommand = value;;
}
// Serial.print("Brightness ");Serial.println(brightness);
// Serial.print("Brightness ");Serial.println(brightness);
}
if (fireworks)
{
fireworks_routine();
}
else if (sound_control)
{
mikro();
} else
{
for (int i = 0; i < NUM_LEDS; i++)
{ if (s[0].white) { // using it as a normal white reading lamp
red = green = blue = s[0].brightness;
red = red * 120 / 100;
} else { // wave generation
phaseR = (long)((long)s[0].zeit * s[0].waveFrequency / 10000) & 255; // red wave
phaseG = ((int)(phaseR + 256 / 3)) & 255; // green wave offset by 2/3 pi
phaseB = ((int)(phaseR + 256 * 2 / 3)) & 255; // blue wave offset by 4/3 pi
red = (sin_wave((phaseR + i * s[0].width / 5) & 255) + 128) * s[0].brightness / 256 ; // develop wave along strip limit current with global white scaling
blue = (sin_wave((phaseB + i * s[0].width / 5) & 255) + 128) * s[0].brightness / 256;
green = (sin_wave((phaseG + i * s[0].width / 5) & 255) + 128) * s[0].brightness / 256 ;
if (false) {
Serial.print (red);
Serial.print (" ");
Serial.print (blue);
Serial.print (" ");
Serial.println (green);
}
};
pixels.setPixelColor(i, pixels.Color(red, green, blue)); // Moderately bright green color.
};
};
// Display whatever you have created in leds[] but do not disturb ongoing receiption if IR command
if (irrecv.isIdle()) { //warte bis Fernbedienung fertig
pixels.show(); // This sends the updated pixel color to the hardware.
// FastLED.show();
}
delay(1000 / s[0].updateFrequency);
}
Hi,
http://gist.github.com is where you want to be posting code.
Hello @Walter_Rorschach Cool project and thank you for sharing the details! Can you edit and delete the code from your last post and put in on http://gist.github.com ? This way G+ won’t mangle the code, the code can be viewed correctly on all devices, and line numbers can be referenced for discussion if needed.
Nothing wrong with FORTRAN. 
Walter, I use APA102 LED’s, which allows me to use both IR as well as a Fourier library along with FastLED on my Arduino Nano’s.