// a 120*WS2812B (screenmatrix) +16x WS2812 (above, lives and waponpower) + 8dig led (score etc..) superbright+colorfull Acardegamingproject //controler: current 2axes console analogjoistig with pushjtaster and 4tasters cros (3Watt RGB in controllerplatine for effects) // i want the glow Atro Commander verry old lcd acarde game but its expensive and never money so build my own (maybe also snake, other games ) in a verry bright vision // the 120 WS2812B have a total factory rated powerconsumtion from 30Watts (purrrr this is even psychedwelic bright if somany) //cutrrent controllertest working fine its calibrated.. now have do martenkode the games i want // fastled lib SmartMatrix function haven worked so find my own system caused its faster to write own than try to get the example working.. //its free use it or parts if something usefull [MEOW] =^.^= //** Serial 3 is connectet to 433Mhz rx/tx RF modules, maybe let pc play the gemesound.. or use serial2 sor serial mp3 player don't know.. // 3gp video from testing this running kote http://marderchen.de/NEU/120xWS2812B_acardematrix_purrgamepadworking+calibrated.3gp // video from rainbowtesting matrix http://marderchen.de/NEU/120xWS2812B_selfbuildacardematrix_rainbowtest.3gp /* * pictures: * http://marderchen.de/NEU/120x_WS2812B_30Watt-ledcolormatrix_gamepad.jpg * http://marderchen.de/NEU/120xWS2812B_matrixtest_5Vunlimited-Ampere_test.jpg * http://marderchen.de/NEU/120x-ws2812B_Matrix10x12_fordrivewith_factoryrated_30watt.jpg for using maximum efficience and brighteness its a mass cooper (NYM 1,5mm˛) wire on read for cooling and optimal power to spread, capacitors for Stabilasing voltage: 6x 1000yF 10V (for 5V) 2x 1000yF in controller for 3v3 and 5v) * http://marderchen.de/NEU/120xWS2812B_matrix_testfine.jpg */ #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 mews = "Purrrrrr "; //const char message []= "Start config"; #include #define LED_PIN PB8 //DIN connect to pin B8 #define BRIGHTNESS 255 #define LED_TYPE WS2812B #define COLOR_ORDER GRB #define screeny 136 //number of leds CRGB leds[screeny]; CRGBPalette16 currentPalette; TBlendType currentBlending; #define UPDATES_PER_SECOND 5000 extern CRGBPalette16 myRedWhiteBluePalette; #define rot PA8 #define grun PB15 #define blau PB14 #define t1 PB10 #define t2 PB11 #define t3 PB5 #define t4 PA10 #define t5 PA9 #define achsex PA0 #define achsey PA1 int mwidth= 12; int mhight=10; int16_t matrix[13][11][3]; long maintime = millis(); int zeit1,zeit2; int xj=0; int yj=0; int8_t onpress[17]; void setup(){ delay(1000); display.begin(); Serial3.begin(9600); FastLED.addLeds(leds, screeny).setCorrection( TypicalLEDStrip ); FastLED.setBrightness( BRIGHTNESS ); currentPalette = RainbowColors_p; currentBlending = BLEND; } void loop(){ zeitreise(); clearleds(); joy(); buttons(); matrix[xj][yj][3]=1; regenbogen(); scratchdigs(); FastLED.show(); FastLED.delay(1000 / 15000); } void joy(void) { xj= round((4096-analogRead(achsex))/341); yj= round(analogRead(achsey)/410); } void buttons() { if (zeit2 >=1) { if (digitalRead(t1) == HIGH && onpress[0] ==0) { onpress[0] =1; } if (onpress[0] == 1) { onpress[1]++; leds[121]=ColorFromPalette( currentPalette,onpress[1]*5,255,currentBlending); }//spiel(melodie2); if (onpress[1] >= 10) { onpress[1] =0; onpress[0]=0; } if (digitalRead(t2) == HIGH && onpress[2] ==0) { onpress[2] =1; } if (onpress[2] == 1) { onpress[3]++; leds[122]=ColorFromPalette( currentPalette,onpress[3]*10,255,currentBlending); } if (onpress[3] >= 10) { onpress[3] =0; onpress[2]=0; } if (digitalRead(t3) == HIGH && onpress[4] ==0) { onpress[4] =1; } if (onpress[4] == 1) { onpress[5]++; leds[123]=ColorFromPalette( currentPalette,onpress[5]*15,255,currentBlending); } if (onpress[5] >= 10) { onpress[5] =0; onpress[4]=0; } if (digitalRead(t4) == HIGH && onpress[6] ==0) { onpress[6] =1;} if (onpress[6] == 1) { onpress[7]++; leds[124]=ColorFromPalette( currentPalette,onpress[7]*20,255,currentBlending); } if (onpress[7] >= 10) { onpress[7] =0; onpress[6]=0; } if (digitalRead(t5) == HIGH && onpress[8] ==0) { onpress[8] =1; } if (onpress[8] == 1) { onpress[9]++; leds[125]=ColorFromPalette( currentPalette,onpress[9]*25,255,currentBlending); } if (onpress[9] >= 10) { onpress[9] =0; onpress[8]=0; } zeit2=0; }} void clearleds(void) { for( int xxx= 0; xxx < mwidth; xxx++) { for( int yyy= 0; yyy < mhight; yyy++) {matrix[xxx][yyy][3]=0;}} for( int live= 121; live < 136; live++) { leds[live]=CRGB::Black;} } int zeitk=0; int color2=0; int color=0; int speedz=0; int merkup=0; int positron=0; void regenbogen(void){ if (merkup==0) {color2++;} // if (merkup==1) {color2--;} if (color2 > 4096) {color2=0; } // if (color2 < 0) {merkup=0;} color=color2; positron=0; for( int xx= 0; xx < mwidth; xx++) { for( int yy= 0; yy < mhight; yy++) { color++; if (matrix[xx][yy][3]==0){ leds[positron]= 0x000000;} if (matrix[xx][yy][3]==1){ leds[positron]= 0xffffff;} if (matrix[xx][yy][3]==2){ leds[positron]= 0xff0000;} if (matrix[xx][yy][3]==3){ leds[positron]= 0xffff00;} if (matrix[xx][yy][3]==4){ leds[positron]= 0x00ff00;} if (matrix[xx][yy][3]==5){ leds[positron]= 0x00ffff;} if (matrix[xx][yy][3]==6){ leds[positron]= 0x0000ff;} if (matrix[xx][yy][3]==7){ leds[positron]= 0xff00ff;} if (matrix[xx][yy][3]==8){ matrix[xx][yy][0]=color; matrix[xx][yy][1]=sin(color/360)*360; leds[positron]=ColorFromPalette( currentPalette,matrix[xx][yy][0], matrix[xx][yy][1],currentBlending);} positron++; }}} int denda,blinkz; void scratchdigs() { mews =""; if(xj <=9) {mews+="0";} if(xj <=99) {mews+="0";} if(xj <=999) {mews+="0";} if(xj <=9999) {mews+="0";} mews += String(xj); if(yj <=9) {mews+="0";} if(yj <=99) {mews+="0";} if(yj <=999) {mews+="0";} if(yj <=9999) {mews+="0";} mews += String(yj); for (int i = 0; i < 8; i++){ display.sendChar (i, mews[i]); if (i == denda && (blinkz >8)) {display.sendChar (i, ' '); } } } void zeitreise(void){ while ((millis()- maintime) >= 10) { zeit1++; zeit2++; if(zeit1 > zeitk) { speedz++;zeit1=0;} if (speedz > 200) { speedz = 0; zeitk=random(20,50);} maintime = millis(); } }