//fastled colorpallet.ino verwuselt by marderchen for rainbow headphones soundvisu=^.^= MEOW (controling 48 WS2812 LEDs on PB7 with analog audio input) #define t1 PB12 #define t2 PB13 #define t3 PB14 #define t4 PB15 #define t5 PA8 #define t6 PB11 #define t7 PB10 #define t8 PB0 #define tshine PA5 #define trechts PA4 #define tlinks PA3 #define mrechts PA2 #define mlinks PA1 #define rot PB11 #define grun PB10 #define blau PB5 #define uv PB4 #define pruf PB5 long allfcount = micros(); long maintime = millis(); int onpress[17]; int zeit1 =0; long zeita =10; //untervallspeed int zeitr=10; int zeitb =10; //anzeitverlängerung int zeitc =30; //auszeitverlängerung int teiler =1; //emfpindlichkeit int fcount1 =0; int present =2; int soundi =0; int soundi2 =0; int soundminimum =2; int setled=10; int setled3=10; int setled4=10; int colorindex2 =0; int setled2 =10; int zeit2=0; int volcount =0; int ka =0; //fastled #include #define LED_PIN PB7 #define NUM_LEDS 48 #define BRIGHTNESS 255 #define LED_TYPE WS2812 #define COLOR_ORDER GRB CRGB leds[NUM_LEDS]; CRGBPalette16 currentPalette; TBlendType currentBlending; #define UPDATES_PER_SECOND 100 extern CRGBPalette16 myRedWhiteBluePalette; extern const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM; //end void setup() { pinMode(pruf, OUTPUT); pinMode(t1, INPUT); pinMode(t2, INPUT); pinMode(t3, INPUT); pinMode(t4, INPUT); pinMode(t5, INPUT); pinMode(t6, INPUT); pinMode(t7, INPUT); pinMode(t8, INPUT); delay( 3000 ); // power-up safety delay FastLED.addLeds(leds, NUM_LEDS).setCorrection( TypicalLEDStrip ); FastLED.setBrightness( BRIGHTNESS ); currentPalette = RainbowColors_p; //thanks for the cute rainbow currentBlending = BLEND; } void loop() { zeitreise(); // istinput(); rechneplasma(); voladjust(); if (analogRead(sound) > 10) {soundi = analogRead(sound)-zeitc;} if (analogRead(soundb) > 10) {soundi2 = analogRead(sound)-zeitc; } static uint8_t startIndex = 0; startIndex = startIndex + setled/1.5; /* motion speed */ //SetupTotallyRandomPalette(); colorindex2 = startIndex +20; FillLEDsFromPaletteColors( startIndex); FastLED.show(); FastLED.delay(1000 / UPDATES_PER_SECOND); } void istinput(void){ if (zeit1 >=1) { if (digitalRead(t1) == HIGH && onpress[0] ==0) { onpress[0] =1; } //minisound if (onpress[0] == 1) { onpress[1]++;} if (onpress[1] == 2) { if (soundminimum >3) {soundminimum-=1;} digitalWrite(pruf, HIGH );} //tudinge if (onpress[1] >= 10) { onpress[1] =0; onpress[0]=0; digitalWrite(pruf, LOW );} if (digitalRead(t2) == HIGH && onpress[2] ==0) { onpress[2] =1; } if (onpress[2] == 1) { onpress[3]++;} if (onpress[3] == 2) { if (soundminimum <4000) {soundminimum+=1;} digitalWrite(pruf, HIGH );} //tudinge if (onpress[3] >= 10) { onpress[3] =0; onpress[2]=0; digitalWrite(pruf, LOW );} if (digitalRead(t3) == HIGH && onpress[4] ==0) { onpress[4] =1; } if (onpress[4] == 1) { onpress[5]++;} if (onpress[5] == 2) { teiler--; digitalWrite(pruf, HIGH );} //tudinge if (onpress[5] >= 10) { onpress[5] =0; onpress[4]=0; digitalWrite(pruf, LOW );} if (digitalRead(t4) == HIGH && onpress[6] ==0) { onpress[6] =1; } if (onpress[6] == 1) { onpress[7]++;} if (onpress[7] == 2) { teiler++; digitalWrite(pruf, HIGH );} //tudinge if (onpress[7] >= 10) { onpress[7] =0; onpress[6]=0; digitalWrite(pruf, LOW );} if (digitalRead(t5) == HIGH && onpress[8] ==0) { onpress[8] =1; } if (onpress[8] == 1) { onpress[9]++;} if (onpress[9] == 2) { zeitb--; digitalWrite(pruf, HIGH );} //tudinge if (onpress[9] >= 10) { onpress[9] =0; onpress[8]=0; digitalWrite(pruf, LOW );} if (digitalRead(t6) == HIGH && onpress[10] ==0) { onpress[10] =1; } if (onpress[10] == 1) { onpress[11]++;} if (onpress[11] == 2) { zeitb++; digitalWrite(pruf, HIGH );} //tudinge if (onpress[11] >= 10) { onpress[11] =0; onpress[10]=0; digitalWrite(pruf, LOW );} if (digitalRead(t7) == HIGH && onpress[12] ==0) { onpress[12] =1; } //zeitc -signal if (onpress[12] == 1) { onpress[13]++;} if (onpress[13] == 2) { zeitc-=4; digitalWrite(pruf, HIGH );} //tudinge if (onpress[13] >= 10) { onpress[13] =0; onpress[12]=0; digitalWrite(pruf, LOW );} if (digitalRead(t8) == HIGH && onpress[14] ==0) { onpress[14] =1; } if (onpress[14] == 1) { onpress[15]++;} if (onpress[15] == 2) {zeitc+=2; digitalWrite(pruf, HIGH );} //tudinge if (onpress[15] >= 10) { onpress[15] =0; onpress[14]=0; digitalWrite(pruf, LOW );} zeit1=0; }} void zeitreise(void){ while ((millis()- maintime) >= 10) { zeit1++; zeit2++; ka++; maintime = millis(); } } void voladjust (void){ if (zeit2 >= 25 && setled <10) {zeitc--; zeit2 =0;} if (zeit2 >= 25 && setled >10) {zeitc++; zeit2=0;} } void rechneplasma(void){ zeita = ((soundi /teiler)) +zeitb; zeitr = ((soundi2 /teiler)) +zeitb; if (setled2 < zeita && setled2 < (NUM_LEDS/2)) {setled2++;} if (setled2 > zeita) {setled2--;} if (setled3 < zeitr && setled3 < (NUM_LEDS/2)) {setled3++;} if (setled3 > zeitr) {setled3--;} while ((micros()- allfcount) >= 15) { if (setled < zeita && setled < (NUM_LEDS/2)) {setled++;} if (setled > zeita) {setled--;} if (setled4 < zeitr && setled4 < (NUM_LEDS/2)) {setled4++;} if (setled4 > zeitr) {setled4--;} allfcount = micros(); }} void FillLEDsFromPaletteColors( uint8_t colorIndex) { uint8_t brightness = 117+ (ka*6); if (ka >24) {ka=0;} for( int i = 0; i < NUM_LEDS; i++) { switch (present) { case 1: if (i < setled) {leds[i] = ColorFromPalette( currentPalette, colorIndex, brightness, currentBlending);} if (i < setled4) {leds[(NUM_LEDS-i)-1] = ColorFromPalette( currentPalette, colorIndex, brightness, currentBlending);} if (i> setled && i< 20) { leds[i] = CRGB::Black; } if (i> setled4 && i< 20) { leds[(NUM_LEDS-i)-1] = CRGB::Black;} if ( i == (ka+1)| i == (ka-1) ) { leds[i] = CRGB::Black; leds[(NUM_LEDS-i)-1] = CRGB::Black;} if ( i == ka ) { leds[i] = CRGB::White; leds[(NUM_LEDS-i)-1] = CRGB::White;} if (i == (setled2 +3)) {leds[i] = ColorFromPalette( currentPalette, colorindex2, brightness, currentBlending);} if (i == (setled3 +3)) {leds[(NUM_LEDS-i)-1] = ColorFromPalette( currentPalette, colorindex2, brightness, currentBlending);} colorIndex += 1+(setled/3); colorindex2 += setled; break; case 2: break; }} } //programm by marderchen =^.^= /* MMMMMMMM MMMMMMMMEEEEEEEEEEEEEEEEEEEEEE OOOOOOOOO WWWWWWWW WWWWWWWW M:::::::M M:::::::ME::::::::::::::::::::E OO:::::::::OO W::::::W W::::::W M::::::::M M::::::::ME::::::::::::::::::::E OO:::::::::::::OO W::::::W W::::::W M:::::::::M M:::::::::MEE::::::EEEEEEEEE::::EO:::::::OOO:::::::OW::::::W W::::::W M::::::::::M M::::::::::M E:::::E EEEEEEO::::::O O::::::O W:::::W WWWWW W:::::W M:::::::::::M M:::::::::::M E:::::E O:::::O O:::::O W:::::W W:::::W W:::::W M:::::::M::::M M::::M:::::::M E::::::EEEEEEEEEE O:::::O O:::::O W:::::W W:::::::W W:::::W M::::::M M::::M M::::M M::::::M E:::::::::::::::E O:::::O O:::::O W:::::W W:::::::::W W:::::W M::::::M M::::M::::M M::::::M E:::::::::::::::E O:::::O O:::::O W:::::W W:::::W:::::W W:::::W M::::::M M:::::::M M::::::M E::::::EEEEEEEEEE O:::::O O:::::O W:::::W W:::::W W:::::W W:::::W M::::::M M:::::M M::::::M E:::::E O:::::O O:::::O W:::::W:::::W W:::::W:::::W M::::::M MMMMM M::::::M E:::::E EEEEEEO::::::O O::::::O W:::::::::W W:::::::::W M::::::M M::::::MEE::::::EEEEEEEE:::::EO:::::::OOO:::::::O W:::::::W W:::::::W M::::::M M::::::ME::::::::::::::::::::E OO:::::::::::::OO W:::::W W:::::W M::::::M M::::::ME::::::::::::::::::::E OO:::::::::OO W:::W W:::W MMMMMMMM MMMMMMMMEEEEEEEEEEEEEEEEEEEEEE OOOOOOOOO WWW WWW `..`... `...... `.. .. `........`....... `........`........ `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `...... `. `.. `...... `...... `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. .. `.. `.. `..`........`........ */