//fastled lib based FurrySonos by marderchen for rainbow fluffy CAT headphones sound visualisation =^.^= MEOW (controling 48 WS2812 LEDs on PB7 with analog stereo audio input in many different ways) // 10steps brightness taster on PA3 #define t1 PA3 //PB12 #define t2 PB13 #define t3 PB14 #define t4 PB15 #define t5 PA8 #define t6 PB11 #define t7 PB10 #define t8 PB0 #define sound PA0 #define soundb PA1 #define pruf PB5 long allfcount = micros(); long maintime = millis(); int onpress[17]; long soundcachL[512]; //cute F103 this is realy big long soundcachR[512]; int brightny[50] ={5,6,9,10,11,15,17,19,21,22,24,25,26,27,29,31,33,35,37,38,41,42,43,45,47,48,51,53,54,55,56,58,59,71,73,76,78,80,84,85,86,89,90,84,95,99,100,101}; int colorys[8] ={1,51,52,53,54,55,56}; int colorfines[25]={1,2,7,48,49,50,51,52,53,54,55,56,57,80,102,103,104,105,106,108,109,110}; int colorsawesome[4]={54,105,106,107,}; int colora=107; int colorfine=0; int brightnessa=0; int colory=0; int zeit1 =0; int zeit3=0; int zeit4=0; long zeita =10; //untervallspeed int zeitr=10; int zeitb =10; //anzeitverlängerung int zeitc =300; //auszeitverlängerung int teiler =1; //emfpindlichkeit int fcount1 =0; int present =3; int presentc =0; int presentcr=0; int presentc2=0; int presentc3=0; int presentc4=0; 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; int taster =10; int peaklowL=0; int peaklowR=0; int peakhighL=150; int peakhighR=150; int peakcach =0; int peakcachR =0; int peakcounter =0; int peakL =0; int peakR =0; int peakslowL =00; int peakslowR =00; int verschiebL=1000; int verschiebR=1000; int barheight=20; int colorIndexe=0; int colorIndexe2=0; int colorchaos=0; int lightchaos=12; uint8_t randomies=0; uint8_t brightness2 = 150; //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 1000 //cute its fast 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;} fillsoundcach(); rechnepeak(); wuselleds(); 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) { taster++; if (taster >=11) {taster=0;} digitalWrite(pruf, HIGH );} //tudinge if (onpress[1] >= 8 && digitalRead(t1) == LOW ) { 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 fillsoundcach(void){ for( int s = 0; s < barheight; s++) { soundi = analogRead(sound)-zeitc; soundi2 = analogRead(sound)-zeitc; zeita = ((soundi /teiler)) +zeitb; zeitr = ((soundi2 /teiler)) +zeitb; soundcachL[s]= zeita; soundcachR[s]=zeitr; }} void wuselleds(void) {//56 if (presentc >2000) { presentc= random(0,1500); presentc2 -= random(0,800); colorchaos=random(0,11); lightchaos=random(0,47); } if (presentc2 >1000) {presentc2= random(0,800); colorchaos=random(12,13); colora = random(0,3); colorfine = random(0,22); } if (presentc3 >2500) {presentc3= random(0,1000); colorchaos=0; colory = random(0,3); } if (presentc4 >2500) {presentc4= random(0,1500); present= random(0,3); } } void rechnepeak(void) { peakcach = peaklowL; peaklowL = peakhighL; peakhighL = peakcach ; for( int p = 0; p < barheight; p++) { if (peaklowL > soundcachL[p]) {peaklowL = soundcachL[p];} if (peakhighL < soundcachL[p]) {peakhighL = soundcachL[p];} } peakL = peakhighL - peaklowL; peakcach = peaklowR; peaklowR = peakhighR; peakhighR = peakcach; for( int p2 = 0; p2 < barheight; p2++) { if (peaklowR > soundcachR[p2]) {peaklowR = soundcachR[p2];} if (peakhighR < soundcachR[p2]) {peakhighR = soundcachR[p2];} if (soundcachR[p2%3] >=peakL) { brightness2 =255;} } peakR = peakhighR - peaklowR; if (peakL > peakslowL) {peakslowL++;} if (peakL < peakslowL) {peakslowL--;} if (peakR > peakslowR) {peakslowR++;} if (peakR < peakslowR) {peakslowR--;} if (zeit3 >1){ if ((peakslowL-verschiebL) >=12) {verschiebL+=2;} if ((peakslowL-verschiebL) <=4) {verschiebL--;} if ((peakslowR-verschiebR) >=12) {verschiebR+=2;} if ((peakslowR-verschiebR) <=4) {verschiebR--;} zeit3=0;} } void zeitreise(void){ while ((millis()- maintime) >= 12) { zeit1++; zeit2++; ka++; zeit3++; presentc++; presentc2++; presentc3++; presentc4++; maintime = millis(); } while ((micros()- allfcount) >= 15) { zeit4++; allfcount = micros(); } } 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--;} if (zeit4 >=1) { if (setled < zeita && setled < (NUM_LEDS/2)) {setled++;} if (setled > zeita) {setled--;} if (setled4 < zeitr && setled4 < (NUM_LEDS/2)) {setled4++;} if (setled4 > zeitr) {setled4--;} zeit4 =0;} } void FillLEDsFromPaletteColors( uint8_t colorIndex) { uint8_t brightness =brightnessa; brightness2 -=((peakslowR-verschiebR)-3)/2; if (ka >24) {ka=0;} peakcounter++; if (peakcounter >=2) {peakcounter =0;} colorIndexe2 -=((peakslowR-verschiebR)-3)/5; if (brightness2 <=0) {brightness2=256;} if (colorIndexe2 <=0) {colorIndexe2=256;} randomies = random(0, 48); for( int i = 0; i < NUM_LEDS; i++) { brightnessa +=((peakslowL-verschiebL)/5)*brightny[lightchaos]; if (brightnessa >=255) {brightnessa=0;} if (brightnessa <=((taster*25)+15)){brightness = 255-(((taster*25)+15)-brightnessa);} if (brightnessa >((taster*25)+15)){brightness = ((taster*25)+15);} brightness2 = 55+(taster*20); barheight =128; leds[i] = CRGB::Black; if ( i <(peakslowL-verschiebL)) {leds[i] = ColorFromPalette( currentPalette, colorIndexe/10,brightness, currentBlending);} if ( (NUM_LEDS-i) <(peakslowR-verschiebR)) {leds[i] = ColorFromPalette( currentPalette, (256-colorIndexe/10), brightness, currentBlending);} if ( i <=24 && i >=21) {leds[i] = ColorFromPalette( currentPalette, colorIndexe, brightness2, currentBlending);} if ( i <=27 && i >=25) {leds[i] = ColorFromPalette( currentPalette, colorIndexe2, (255-brightness2), currentBlending);} switch (present) { case 0: 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);} break; case 1: leds[i] = CRGB::Black; if ( i <(peakslowL-verschiebL)) {leds[i] = ColorFromPalette( currentPalette, soundcachL[128%i], brightness, currentBlending);} if ( (NUM_LEDS-i) <(peakslowR-verschiebR)) {leds[i] = ColorFromPalette( currentPalette, soundcachR[((128%i)-28)], brightness, currentBlending);} break; case 2: if ( i == randomies ) { leds[i] = ColorFromPalette( currentPalette, random(0,256), random(0,256), currentBlending);} break; case 3: if ( i == randomies ) { leds[i] = CRGB::White;} break; } switch (colorchaos) { case 0: colorIndexe +=(((peakslowL-verschiebL)/5)*colorys[colory]); break; case 1: colorIndexe +=(((peakslowL-verschiebL)*32*5)/3); brightness +=(((peakslowL-verschiebL)*32*5)/3); break; case 2: colorIndexe +=(((peakslowL-verschiebL)*36*5)/3); break; case 3: colorIndexe +=(((peakslowL-verschiebL)*64*5)/3); break; case 4: colorIndexe +=(((peakslowL-verschiebL)*96*5)/3); break; case 5: colorIndexe +=(((peakslowL-verschiebL)*85)/3); break; case 6: colorIndexe +=(((peakslowL-verschiebL)*19)/3); case 7: colorIndexe +=(((peakslowL-verschiebL)*1)/3); break; case 8: colorIndexe +=(((peakslowL-verschiebL)*61)/10); break; case 9: colorIndexe +=(((peakslowL-verschiebL)*58)/10); break; case 10: colorIndexe +=((peakslowL-verschiebL)*53); break; case 11: colorIndexe +=((peakslowL-verschiebL)*6); break; case 12: //best colorIndexe +=colorsawesome[colora] /((peakslowL-verschiebL)/5); break; case 13: //best colorIndexe +=colorfines[colorfine] /((peakslowL-verschiebL)/5); 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 `..`... `...... `.. .. `........`....... `........`........ `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `...... `. `.. `...... `...... `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. `.. .. `.. `.. `..`........`........ */