// driver for 6x 8xWS2812 led sticks //raunbowflow down, MAX module and tasters to adjust speed //lled sticks behind 4 layers laserprinting transparent Foil with MEOW letters :3 #include #include #include const byte chips = 1; // 1 chip, bit banged SPI on pins 6, 7, 8 MAX7219 display (chips, PA4, PA7, PA5); // Chips / LOAD / DIN / CLK String outzi = "Purrrrrr "; #include #define screeny 49 //bit longer than stripe CRGBPalette16 currentPalette; TBlendType currentBlending; #define UPDATES_PER_SECOND 5000 extern CRGBPalette16 myRedWhiteBluePalette; CRGB leds[screeny]; uint16_t beat=2246;// need more time for adjusting #define t1 PB14 #define t2 PB13 #define t3 PB15 #define t4 PA8 //7#define t5 PA8 void setup(){ pinMode(t1, INPUT); pinMode(t2, INPUT); pinMode(t3 ,INPUT); pinMode(t4 ,INPUT);// pinMode(t5 ,INPUT); FastLED.addLeds(leds, screeny); FastLED.setBrightness(255); currentPalette = RainbowColors_p; currentBlending = BLEND; delay(300);display.begin();zeigwort("boot",1);delay(100); } uint8_t onpress[12]; uint8_t stepz=0; uint16_t stepcount; void loop(){zeitreise();} long maintime=millis();long littletime=micros();long slowtime=millis(); void zeitreise(void){ while ((millis()- maintime) >= 5){maintime=millis();onpress[10]++;istinput();} while ((millis()- slowtime) >= 100){slowtime = millis();} while ((micros()- littletime) >= (beat*10)){littletime = micros(); stepz+=16;if (stepz>255){stepz=0;}if(stepz>230){zeigzahl(8888,2);}else{zeigzahl(1111,2);} stepcount=stepz; for( int y = 0; y < 8; y++) {stepcount+=32; leds[y] = ColorFromPalette( currentPalette,stepcount,255,currentBlending); leds[y+8] = ColorFromPalette( currentPalette,stepcount,255,currentBlending); leds[y+16] = ColorFromPalette( currentPalette,stepcount,255,currentBlending); leds[y+24] = ColorFromPalette( currentPalette,stepcount,255,currentBlending); leds[y+32] = ColorFromPalette( currentPalette,stepcount,255,currentBlending); leds[y+40] = ColorFromPalette( currentPalette,stepcount,255,currentBlending); } FastLED.show();} } void istinput(void){ if (onpress[10] >2) { if (digitalRead(t1) == HIGH && onpress[0] ==0 && beat <4076) { onpress[0] =1; beat+=20;} if (onpress[0] == 1) { onpress[1]++;} if (onpress[1] >= 10) { onpress[1] =0; onpress[0]=0; } if (digitalRead(t2) == HIGH && onpress[2] ==0 && beat <4086) { onpress[2] =1; beat++; } if (onpress[2] == 1) { onpress[3]++;} if (onpress[3] >= 5) { onpress[3] =0; onpress[2]=0; } if (digitalRead(t3) == HIGH && onpress[4] ==0 && beat >20) { onpress[4] =1; beat-=20; } if (onpress[4] == 1) { onpress[5]++;} if (onpress[5] >= 10) { onpress[5] =0; onpress[4]=0; } if (digitalRead(t4) == HIGH && onpress[6] ==0 && beat >1) { onpress[6] =1; beat--; } if (onpress[6] == 1) { onpress[7]++;} if (onpress[7] >= 5) { onpress[7] =0; onpress[6]=0; } // if (digitalRead(t5) == HIGH && onpress[8] ==0) { onpress[8] =1; } // if (onpress[8] == 1) { onpress[9]++;}if (onpress[9] >= 5) { onpress[9] =0; onpress[8]=0; } onpress[10]=0; zeigzahl(beat,1); }} void zeigzahl(int zahlz,int daa) { outzi=""; if(zahlz <=9) {outzi+="0";} if(zahlz <=99) {outzi+="0";} if(zahlz <=999) {outzi+="0";} outzi+=String(zahlz); if (daa ==1) {for (byte ixx = 0; ixx < 4; ixx++){display.sendChar (ixx, outzi[ixx]);}} if (daa ==2) {for (byte ix2 = 0; ix2 < 4; ix2++){display.sendChar (ix2+4, outzi[ix2]);}} zahlz=0;} void zeigwort(String woortz,int hier) { if (hier == 1){for (int iqq = 0; iqq < 4; iqq++){display.sendChar (iqq, woortz[iqq]);}} if (hier == 2){for (int iq2 = 0; iq2 < 4; iq2++){display.sendChar (iq2+4, woortz[iq2]);}} woortz=""; }