//2 Digs 15 ledchannel 0-99sec timer with 14x NPN D882 transistor, 50 superbright blue 3mm leds and 8 ultrabright red LEDs power by 2x 18650 Li-ion cells and AMS1117 3V3 regulator #define blau7 PA3 //1-ccc #define blau8 PA1 //2->pa1cc #define blau9 PA2//3 pc15 #define blau10 PA0 //4cccc #define blau11 PC15 //6 pa2 #define blau12 PC14 //5 pc14 #define blau13 PC13 //7cccc #define blau0 PB10 //1 #define blau1 PB0 //2 #define blau2 PB1 //3 #define blau3 PA7 //4 #define blau4 PA6 //6 #define blau5 PA5 //5 #define blau6 PA4 //7 #define blau14 PA6 //-- #define rot1 PB11 #define t1 PA15 #define t2 PA12 #define t3 PA10 #define t4 PA9 #define t5 PA8 int16_t digitise[3][8]; //last: color, brighteness, (autocalculatet: redduty,greenduty,blueduty, whitadder, darkadder) int32_t sect =20; int8_t onpress[10]; uint16_t fadefine=200; int ani =199; int aus=0; uint16_t redfade=10; int8_t zeitregen,blinkt,setzen; long maintime=millis(); long maintime2=micros(); long maintime3=millis(); String showme=""; void setup() { pinMode(blau0, OUTPUT); pinMode(blau1, OUTPUT); pinMode(blau2, OUTPUT); pinMode(blau3, OUTPUT); pinMode(blau4, OUTPUT); pinMode(blau5, OUTPUT); pinMode(blau6, OUTPUT); pinMode(blau7, OUTPUT); pinMode(blau8, OUTPUT); pinMode(blau9, OUTPUT); pinMode(blau10, OUTPUT); pinMode(blau11, OUTPUT); pinMode(blau12, OUTPUT); pinMode(blau13, OUTPUT); pinMode(blau14, OUTPUT); pinMode(rot1, OUTPUT); pinMode(t1, INPUT); pinMode(t2, INPUT); pinMode(t3, INPUT); pinMode(t4, INPUT); pinMode(t5, INPUT); } boolean alarm=false; boolean downcount=false;uint16_t alarmsec=0; void loop() { zeitreise(); machlicht(); drueckmich(); if(downcount==false){notime(sect);} if(downcount==true) {notime(alarmsec);} } void drueckmich(void){ if (onpress[4] >=10) { if (digitalRead(t1) == HIGH && onpress[0] ==0 ) { setzen++; if (setzen >2) {setzen=0;} } if (onpress[0] == 1) { onpress[1]++; } if (onpress[1] >= 20) { onpress[1] =0; onpress[0]=0; } if (digitalRead(t2) == HIGH && onpress[2] ==0 ) { onpress[2] =1; setzden(setzen); } if (onpress[2] == 1) { onpress[3]++; } if (onpress[3] >= 5) { onpress[3] =0; onpress[2]=0; } if (digitalRead(t3) == HIGH && onpress[4] ==0 ) { onpress[4] =1; alarm=false;} if (onpress[4] == 1) { onpress[5]++; } if (onpress[5] >= 10) { onpress[5] =0; onpress[4]=0; } if (digitalRead(t4) == HIGH && onpress[6] ==0 ) { onpress[6] =1; alarm=false;} if (onpress[6] == 1) { onpress[7]++; } if (onpress[7] >= 10) { onpress[7] =0; onpress[6]=0; } if (digitalRead(t5) == HIGH && onpress[8] ==0 ) { onpress[8] =1; alarmsec=sect;downcount=true;} if (onpress[8] == 1) { onpress[9]++; } if (onpress[9] >= 10) { onpress[9] =0; onpress[8]=0; } blinkt++; onpress[4]=0; }}//tagrum void setzden(int chosenone) { if (chosenone==0) {} if (chosenone==1) {sect+=1;} if (chosenone==2) {sect+=10;} if (sect >99) {sect=0;} } void notime(int secs){ showme=""; if (secs <=9){showme+="0";} showme+=String(secs); if (blinkt >2) {showme[2-setzen]=' '; }//? if (blinkt >4) {blinkt=0;} } void refresh() { zeigzeugs(0,showme[1]); zeigzeugs(1,showme[0]); } void zeitreise(void){ while ((millis()- maintime) >= 15) { onpress[4]++; if (setzden ==0) {refresh();} if(redfade >4) {redfade-=4;} downfade(); maintime = millis(); } while ((micros()- maintime2) >= 50) {m maintime2 = micros(); } while ((millis()- maintime3) >= 999) { maintime3 = millis(); if (downcount==true && alarmsec >1) {alarmsec--;} if (downcount==true && alarmsec <=1) {downcount=false; alarm=true;} if (alarm==true) {downcount=false; redfade=fadefine;} if (alarm==false) {redfade=0;} refresh(); }} uint8_t steptz=3; void downfade(void) { for (int16_t ad=0; ad <=7; ad++) { if(digitise[0][ad]>steptz) { digitise[0][ad]-=steptz;} if(digitise[1][ad]>steptz) { digitise[1][ad]-=steptz;} }} /*thingy showing 0 in dig "PLAN" dots between are 8 in dig 6(if starting with1 and not 0) first dig from left.. * hihi i know there mus be a better solution better not count the if (s).. * if there is a other solution where i can duty for the 18 colorchanels simultan(sametime) required for fastenough for dutynumberfading.. just flickering if powering one by on * * ---1-- * | | * 3 2 []8 * | | * ---4--- * | | * 5 6 []8 * | | * ---7--- */ void zeigzeugs(int welchezahl,char wasden) { if (wasden == 'S') {wasden='5';} if (wasden == 'e') {wasden='9';} if (wasden == 'R') {wasden='A';} if (wasden == '0') {digitise[welchezahl][1]=ani; digitise[welchezahl][2]=ani; digitise[welchezahl][3]=ani; digitise[welchezahl][4]=aus; digitise[welchezahl][5]=ani; digitise[welchezahl][6]=ani; digitise[welchezahl][7]=ani;} if (wasden == '1') {digitise[welchezahl][1]=aus; digitise[welchezahl][2]=ani; digitise[welchezahl][3]=aus; digitise[welchezahl][4]=aus; digitise[welchezahl][5]=aus; digitise[welchezahl][6]=ani; digitise[welchezahl][7]=aus;} if (wasden == '2') {digitise[welchezahl][1]=ani; digitise[welchezahl][2]=ani; digitise[welchezahl][3]=aus; digitise[welchezahl][4]=ani; digitise[welchezahl][5]=ani; digitise[welchezahl][6]=aus; digitise[welchezahl][7]=ani;} if (wasden == '3') {digitise[welchezahl][1]=ani; digitise[welchezahl][2]=ani; digitise[welchezahl][3]=aus; digitise[welchezahl][4]=ani; digitise[welchezahl][5]=aus; digitise[welchezahl][6]=ani; digitise[welchezahl][7]=ani;} if (wasden == '4') {digitise[welchezahl][1]=aus; digitise[welchezahl][2]=ani; digitise[welchezahl][3]=ani; digitise[welchezahl][4]=ani; digitise[welchezahl][5]=aus; digitise[welchezahl][6]=ani; digitise[welchezahl][7]=aus;} if (wasden == '5') {digitise[welchezahl][1]=ani; digitise[welchezahl][2]=aus; digitise[welchezahl][3]=ani; digitise[welchezahl][4]=ani; digitise[welchezahl][5]=aus; digitise[welchezahl][6]=ani; digitise[welchezahl][7]=ani;} if (wasden == '6') {digitise[welchezahl][1]=ani; digitise[welchezahl][2]=aus; digitise[welchezahl][3]=ani; digitise[welchezahl][4]=ani; digitise[welchezahl][5]=ani; digitise[welchezahl][6]=ani; digitise[welchezahl][7]=ani;} if (wasden == '7') {digitise[welchezahl][1]=ani; digitise[welchezahl][2]=ani; digitise[welchezahl][3]=aus; digitise[welchezahl][4]=aus; digitise[welchezahl][5]=aus; digitise[welchezahl][6]=ani; digitise[welchezahl][7]=aus;} if (wasden == '8') {digitise[welchezahl][1]=ani; digitise[welchezahl][2]=ani; digitise[welchezahl][3]=ani; digitise[welchezahl][4]=ani; digitise[welchezahl][5]=ani; digitise[welchezahl][6]=ani; digitise[welchezahl][7]=ani;} if (wasden == '9') {digitise[welchezahl][1]=ani; digitise[welchezahl][2]=ani; digitise[welchezahl][3]=ani; digitise[welchezahl][4]=ani; digitise[welchezahl][5]=aus; digitise[welchezahl][6]=ani; digitise[welchezahl][7]=ani;} if (wasden == ' ') {digitise[welchezahl][1]=aus; digitise[welchezahl][2]=aus; digitise[welchezahl][3]=aus; digitise[welchezahl][4]=aus; digitise[welchezahl][5]=aus; digitise[welchezahl][6]=aus; digitise[welchezahl][7]=aus;} if (wasden == 'A') {digitise[welchezahl][1]=ani; digitise[welchezahl][2]=ani; digitise[welchezahl][3]=ani; digitise[welchezahl][4]=ani; digitise[welchezahl][5]=ani; digitise[welchezahl][6]=ani; digitise[welchezahl][7]=aus;} if (wasden == 'L') {digitise[welchezahl][1]=aus; digitise[welchezahl][2]=aus; digitise[welchezahl][3]=ani; digitise[welchezahl][4]=aus; digitise[welchezahl][5]=ani; digitise[welchezahl][6]=aus; digitise[welchezahl][7]=ani;} if (wasden == 't') {digitise[welchezahl][1]=ani; digitise[welchezahl][2]=ani; digitise[welchezahl][3]=ani; digitise[welchezahl][4]=aus; digitise[welchezahl][5]=ani; digitise[welchezahl][6]=aus; digitise[welchezahl][7]=ani;} if (wasden == 'i') {digitise[welchezahl][1]=aus; digitise[welchezahl][2]=aus; digitise[welchezahl][3]=aus; digitise[welchezahl][4]=aus; digitise[welchezahl][5]=aus; digitise[welchezahl][6]=ani; digitise[welchezahl][7]=aus;} if (wasden == 'm') {digitise[welchezahl][1]=aus; digitise[welchezahl][2]=aus; digitise[welchezahl][3]=aus; digitise[welchezahl][4]=ani; digitise[welchezahl][5]=ani; digitise[welchezahl][6]=ani; digitise[welchezahl][7]=aus;} if (wasden == 'H') {digitise[welchezahl][1]=aus; digitise[welchezahl][2]=ani; digitise[welchezahl][3]=ani; digitise[welchezahl][4]=ani; digitise[welchezahl][5]=ani; digitise[welchezahl][6]=ani; digitise[welchezahl][7]=aus;} if (wasden == 'o') {digitise[welchezahl][1]=aus; digitise[welchezahl][2]=aus; digitise[welchezahl][3]=aus; digitise[welchezahl][4]=ani; digitise[welchezahl][5]=ani; digitise[welchezahl][6]=ani; digitise[welchezahl][7]=ani;} if (wasden == 'U') {digitise[welchezahl][1]=aus; digitise[welchezahl][2]=ani; digitise[welchezahl][3]=ani; digitise[welchezahl][4]=aus; digitise[welchezahl][5]=ani; digitise[welchezahl][6]=ani; digitise[welchezahl][7]=ani;} if (wasden == 'E') {digitise[welchezahl][1]=ani; digitise[welchezahl][2]=aus; digitise[welchezahl][3]=ani; digitise[welchezahl][4]=ani; digitise[welchezahl][5]=ani; digitise[welchezahl][6]=aus; digitise[welchezahl][7]=ani;} if (wasden == 'C') {digitise[welchezahl][1]=ani; digitise[welchezahl][2]=aus; digitise[welchezahl][3]=ani; digitise[welchezahl][4]=aus; digitise[welchezahl][5]=ani; digitise[welchezahl][6]=aus; digitise[welchezahl][7]=ani;} //see how simple it is brain :3 } long startriger=micros(); void machlicht(void) { while ((micros()-startriger) >= 20) { for (int16_t fcount1=0; fcount1 <(fadefine+2); fcount1++) { if (fcount1 == 0) {noled();} if (fcount1 <= fadefine && fcount1>=1) { if (fcount1 == ((fadefine)-digitise[0][1])) { digitalWrite(blau0, HIGH );} if (fcount1 == ((fadefine)-digitise[0][2])) { digitalWrite(blau1, HIGH );} if (fcount1 == ((fadefine)-digitise[0][3])) { digitalWrite(blau2, HIGH );} if (fcount1 == ((fadefine)-digitise[0][4])) { digitalWrite(blau3, HIGH );} if (fcount1 == ((fadefine)-digitise[0][5])) { digitalWrite(blau4, HIGH );} if (fcount1 == ((fadefine)-digitise[0][6])) { digitalWrite(blau5, HIGH );} if (fcount1 == ((fadefine)-digitise[0][7])) { digitalWrite(blau6, HIGH );} if (fcount1 == ((fadefine)-digitise[1][1])) { digitalWrite(blau7, HIGH );} if (fcount1 == ((fadefine)-digitise[1][2])) { digitalWrite(blau8, HIGH );} if (fcount1 == ((fadefine)-digitise[1][3])) { digitalWrite(blau9, HIGH );} if (fcount1 == ((fadefine)-digitise[1][4])) { digitalWrite(blau10, HIGH );} if (fcount1 == ((fadefine)-digitise[1][5])) { digitalWrite(blau11, HIGH );} if (fcount1 == ((fadefine)-digitise[1][6])) { digitalWrite(blau12, HIGH );} if (fcount1 == ((fadefine)-digitise[1][7])) { digitalWrite(blau13, HIGH );} if (fcount1 == ((fadefine)-redfade)) { digitalWrite(rot1, HIGH );}} if (fcount1 >= (fadefine+1)) {noled();} } startriger = micros(); } } void noled(void) { digitalWrite(blau0, LOW ); digitalWrite(blau1, LOW ); digitalWrite(blau2, LOW ); digitalWrite(blau3, LOW ); digitalWrite(blau4, LOW ); digitalWrite(blau5, LOW ); digitalWrite(blau6, LOW ); digitalWrite(blau7, LOW ); digitalWrite(blau8, LOW ); digitalWrite(blau9, LOW ); digitalWrite(blau10, LOW ); digitalWrite(blau11, LOW ); digitalWrite(blau12, LOW ); digitalWrite(blau13, LOW ); digitalWrite(rot1, LOW );} //[MEOW] project by marderchen us3e it or parts if usefull :3