//marten Kote for new Atomizer remote holder caqused old mouse one totaly destroid by faling down and electrolyse by liquid on tasters and contacts.. also some wires not longer working sone to much moving.. //its free do with it or parts whatever you want.. if its usefull.. (not the best solution but working fine.. maybe upgrade device comday caused free i/os left) //MEOW have fun #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 message = "Purrrrrr "; #define rot1 PA8 #define grun1 PB6 #define blau1 PB7 #define rot PC15 #define grun PC14 #define blau PC13 #define UV PA0 #define heat PA1 #define t1 PB12 //tisch #define t2 PB13 //up #define t3 PB14 //down #define t4 PB8 //heizen long puffs=0; int puffset=0; int8_t onpress[10]; int duty[10]; int power=170; int fcount2=0; int powerb,digmove; long maintime=millis(); long maintime2=micros(),startriger=micros(); int zeit1,zeit2,zeit3,zeit4,zeit5,zeit6,sonne; boolean saver =false,vape=false; int16_t rainbow; int16_t bright =300; void setup() { pinMode(rot, OUTPUT);pinMode(grun, OUTPUT);pinMode(blau, OUTPUT);pinMode(UV, OUTPUT);pinMode(heat, OUTPUT); pinMode(rot1, OUTPUT);pinMode(grun1, OUTPUT);pinMode(blau1, OUTPUT); pinMode(t1, INPUT);pinMode(t2, INPUT);pinMode(t3 ,INPUT);pinMode(t4 ,INPUT); delay(500); display.begin (); Serial3.begin(57600);//PB10 TX PB11 RX } void loop() { zeitreise();} int16_t brightc,brightcc,nenrandy,rainc,powerbe,cach1,cach2,cach3,brightmax; void autocolor(void){ powerb=(power+brightmax)/2; if (zeit5 >200) { rainc=random(0,10);zeit5=random(0,150);} if (zeit2 >rainc) {rainbow++; zeit2=0;} if (zeit3 >200) {nenrandy=random(0,30); if (nenrandy <14) {brightc=random(20,powerb); brightcc=random(1,5);zeit3=random(0,90); } if (nenrandy >= 14 && nenrandy < 18) {brightc=random(100,powerb*1.5); brightcc=random(2,7); zeit3=random(20,100); } if (nenrandy >= 18) {brightc=random(400,powerb*2.5); brightcc=random(1,5);zeit3=random(0,50); } } if(zeit4 > brightcc) { if (bright > brightc) {bright--;} if (bright < brightc) {bright++;}zeit4=0;} cach1=((brightc/1.5)+(duty[0]*1.5))/2; cach2=((bright/2)+(duty[1]*1.5))/2; cach3=((zeit3+zeit5)+(duty[2]*2))/2; if (duty[3]> ((brightcc+rainc+(zeit3/20))*10)) {duty[3]--;} if (duty[3]< ((brightcc+rainc+(zeit3/20))*10)) {duty[3]++;} if(zeit6>100) { if (digitalRead(t1)== LOW && puffset==0) {saver==true; scratchdigs();} if (digitalRead(t1)== HIGH && puffset==0) {saver==false; saverdigs();} if (duty[4] < cach1) {duty[4]++;} if (duty[5] < cach2) {duty[5]++;} if (duty[6] < cach3) {duty[6]++;} if (duty[4] > cach1) {duty[4]--;} if (duty[5] > cach2) {duty[5]--;} if (duty[6] > cach3) {duty[6]--;} zeit5=0; } } void istinput(void){zeit1++; if (zeit1 >=2) { if (digitalRead(t2) == HIGH && onpress[2] ==0) { onpress[2] =1; if (power >1) {power--;}Serial3.print(round(power/4));Serial3.print("v");scratchdigs();} 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; if (power <398) {power++;} Serial3.print(round(power/4));Serial3.print("v");scratchdigs(); } if (onpress[4] == 1) { onpress[5]++;} if (onpress[5] >= 5) { onpress[5] =0; onpress[4]=0; } if (digitalRead(t2) == HIGH && digitalRead(t3) == HIGH && onpress[6] ==0) { onpress[6] =1; brightmax+=20; if (brightmax >400) {brightmax=0;}} if (onpress[6] == 1) { onpress[7]++;} if (onpress[7] >= 5) { onpress[7] =0; onpress[6]=0; } if (onpress[1] >1 || onpress[3] >1 || onpress[5] >1 || onpress[7] >1) { duty[3]=400;} if (duty[4] > 2) {duty[4]-=10;} if (digitalRead(t4) == HIGH){vape=true;duty[0]=399;} if (digitalRead(t4) == LOW){vape=false;} zeit1=0; } if (digmove <100) {digmove++;} } long timez= millis(); long runtime=0; void zeitreise(void){ while ((millis()- maintime) >= 5) { istinput(); zeit3++; zeit5++; maintime = millis(); } while ((micros()- maintime2) >= 400) { autocolor(); zeit2++; zeit4++; maintime2 = micros(); } while ((millis()- timez) >= 100) { runtime++; zeit6++; timez = millis(); } while ((micros()-startriger) >= 200) { machlicht();//callOLED(); startriger = micros();} } void rainbowcalc(void) { if(rainbow >=0 && rainbow <=400) {duty[0] =400; duty[1] =rainbow; duty[2] =0;} //rot ->gelb (rotmax grün+ blau0) if(rainbow >=401 && rainbow <=801) {duty[0] =(400 -(rainbow -401)); duty[1] =400; duty[2] =0;} //gelb ->grün (rot- grünmax blau0) if(rainbow >=802 && rainbow <=1202) {duty[0] =0; duty[1] =400; duty[2] =(rainbow - 802);} //grün ->cyan (rot0 grünmax blau+) if(rainbow >=1203 && rainbow <=1603) {duty[0] =0; duty[1] =(400 -(rainbow - 1203)); duty[2] =400;} //cyan ->blau (rot0 grün- blaumax) if(rainbow >=1604 && rainbow <=2004) {duty[0] =(rainbow-1604); duty[1] =0; duty[2] =400;} //blau ->lila (rot+ grün0 blaumax) if(rainbow >=2005 && rainbow <=2405) {duty[0] =400; duty[1] =0; duty[2] =(400- (rainbow -2006));} //lila ->rot (rotmax grün0 blau-) if(rainbow >= 2406) {rainbow =0;} duty[4]= duty[0]*1.5; duty[5]= duty[1]*1.5; duty[6]= duty[2]*2; } uint16_t light,darkness,dcach,difder=2; void machlicht(void) { rainbowcalc(); if (bright > 400){light=bright-400; dcach=0;} if (bright <=400){dcach=(400-(bright))/2; light=0;} darkness=(dcach*dcach)/1.8; for (uint16_t fcount2=0; fcount2 < 403; fcount2++) { if (fcount2 == (401-round(duty[0]/difder))) { digitalWrite(rot, HIGH );}//3Watt if (fcount2 == (401-round(duty[1]/difder))) { digitalWrite(grun, HIGH );} if (fcount2 == (401-round(duty[2]/difder))) { digitalWrite(blau, HIGH );} if (fcount2 == (401-duty[3])) { digitalWrite(UV, HIGH );} if (fcount2 == (401-duty[4])) { digitalWrite(rot1, HIGH );}//STRAW if (fcount2 == (401-duty[5])) { digitalWrite(grun1, HIGH );} if (fcount2 == (401-duty[6])) { digitalWrite(blau1, HIGH );} if (fcount2 == (401-power)) {if(vape==true){ digitalWrite(heat, HIGH ); }puffset=1; } if (fcount2 >= (402) ) { digitalWrite(rot, LOW ); digitalWrite(grun, LOW ); digitalWrite(blau, LOW ); digitalWrite(rot1, LOW ); digitalWrite(grun1, LOW ); digitalWrite(blau1, LOW ); digitalWrite(UV, LOW ); digitalWrite(heat, LOW ); }}} String cachb=""; String cach=""; void callOLED(void) { while(Serial3.available()>0) { int cachs = Serial3.read(); cachb = ""; cachb += (char)cachs; if (isDigit(cachs)) { cach += (char)cachs;} if ( cachb == "k") { power= cach.toInt(); cach ="";cachb =""; }}} int8_t denda=0; int16_t blinkz=0; long printtime=0; String outzi=""; void scratchdigs() { printtime = power; outzi=""; if(printtime <=9) {outzi+="0";} if(printtime <=99) {outzi+="0";} if(printtime <=999) {outzi+="0";} if(printtime <=9999) {outzi+="0";} outzi+=String(printtime); outzi+=" Uat"; for (byte i = 0; i < 8; i++){ display.sendChar (i, outzi[i+1]); } } int digmoveb,digmovec; void saverdigs() { printtime = round(power); outzi=""; if(printtime <=9) {outzi+="0";} if(printtime <=99) {outzi+="0";} if(printtime <=999) {outzi+="0";} if(printtime <=9999) {outzi+="0";} outzi+=String(printtime); outzi+=" UUatt _- purrr -_- "; if(puffs <=9) {outzi+="0";} if(puffs <=99) {outzi+="0";} if(puffs <=999) {outzi+="0";} if(puffs <=9999) {outzi+="0";} if(puffs <=99999) {outzi+="0";} outzi+=String(puffs); outzi+="puffs gone -_- runntime: "; if(runtime <=9) {outzi+="0";} if(runtime <=99) {outzi+="0";} if(runtime <=999) {outzi+="0";} if(runtime <=9999) {outzi+="0";} if(runtime <=99999) {outzi+="0";} if(runtime <=999999) {outzi+="0";} if(runtime <=9999999) {outzi+="0";} outzi+=String(runtime); outzi+=" secs -_- "; if(brightmax <=9) {outzi+="0";} if(brightmax <=99) {outzi+="0";} if(brightmax <=999) {outzi+="0";} outzi+=String(brightmax); outzi+=" light -_- Narderchens Tableuape - Purrrrr - CAT - UUusel hihi -_- "; if (digmove > 12 && digmovec ==0 ) {digmove=0; digmoveb++;} if (digmove > 4 && digmovec ==1 ) {digmove=0; digmoveb--;} if (digmoveb > (outzi.length()-8)) {digmovec=1;} if (digmoveb <=0) {digmovec=0;} for (byte iq = 0; iq < 8; iq++){ display.sendChar (iq, outzi[iq+1+digmoveb]); } }