//its for regulating a 18000upm fan turbine COOLING A 100w CHIPLED as beamer replacementlight working on it //its free do with it or parts whatever you want.. if its usefull.. //MEOW have fun #include #include #include const byte chips = 2; // 1 chip, bit banged SPI on pins 6, 7, 8 MAX7219 display (chips, PA4, PA7, PA5); // Chips / LOAD / DIN / CLK String outzi = "Purrrrrr "; #define rot1 PC13 #define grun1 PC14 #define blau1 PC15 #define white PB9 #define fan PB8 #define rstart PA8 #define t1 PB12 #define t2 PB13 #define t3 PB14 #define t4 PA15 #define t5 PA12 #define rot1f PB7 #define blau1f PB6 #define rot2f PB5 #define blau2f PA10 #define rot3f PA9 #define blau3f PB15 #define rot4f PB10 #define blau4f PB11 #define tMOS PA0 #define tSTEP PA1 #define tALU PA2 #define tLED PA3 #define LDR PB0 uint8_t onpress[10]; int progy=0; long maintime=millis(); long maintime2=micros(); int zeit1; boolean tplusset=false; boolean tminusset=false; boolean tnenset=false; int fansens=46; uint16_t sonne,IRF,ALU,STEP,LED; int lamp=10; int turbine=50; void setup() { pinMode(rot1, OUTPUT); pinMode(grun1, OUTPUT); pinMode(blau1, OUTPUT); pinMode(white, OUTPUT); pinMode(fan, OUTPUT); pinMode(rstart, OUTPUT); pinMode(rot1f, OUTPUT); pinMode(blau1f, OUTPUT); pinMode(rot2f, OUTPUT); pinMode(blau2f, OUTPUT); pinMode(rot3f, OUTPUT); pinMode(blau3f, OUTPUT); pinMode(rot4f, OUTPUT); pinMode(blau4f, OUTPUT); pinMode(t1, INPUT); pinMode(t2, INPUT); pinMode(t3 ,INPUT); pinMode(t4 ,INPUT); pinMode(t5 ,INPUT); delay(300); digitalWrite(rot1f,HIGH);digitalWrite(rot2f,HIGH);digitalWrite(rot3f,HIGH);digitalWrite(rot4f,HIGH); display.begin (); undlos("boot"); digitalWrite(blau1f,HIGH);digitalWrite(blau2f,HIGH);digitalWrite(blau3f,HIGH);digitalWrite(blau4f,HIGH); delay(300); } void loop() { istinput(); zeitreise(); machlicht(); if (progy == 0) {zeigzahl(ALU,1); zeigzahl(LED,2); zeigzahl(STEP,3); zeigzahl(IRF,4); } if (progy == 1) {zeigzahl(LED,1); zeigzahl(ALU,2); zeigzahl(lamp,3); zeigzahl(turbine,4); if (tplusset ==true) {tplusset=false; lamp+=5; if (lamp >2410) {lamp=2410;}} if (tminusset ==true) {tminusset=false; lamp-=2;}} if (progy == 2) {zeigwort("sun ",1); zeigzahl(lamp,2); zeigwort("Fan ",3); zeigzahl(turbine,4); if (tplusset ==true) {tplusset=false; lamp+=20; if (lamp >2410) {lamp=2410;}} if (tminusset ==true) {tminusset=false; lamp-=20;}} if (progy == 3) {zeigwort("sens",1); zeigwort("iv",2); zeigzahl(fansens,2);//stellt 4x blau 3watt if (tplusset ==true) {tplusset=false; fansens+=20; if (fansens >2400) {fansens=2400;}} if (tminusset ==true) {tminusset=false; fansens-=20;} } if (progy == 4) {zeigwort("fan ",1);zeigzahl(turbine,3); zeigwort("cor ",2);zeigzahl(fansens,4);//stellt 4x blau 3watt if (tplusset ==true) {tplusset=false; turbine+=20; if (turbine >2400) {turbine=2400;}} if (tminusset ==true) {tminusset=false; turbine-=20;} } if (progy == 5) {zeigwort("opt ",1); zeigwort("set",2); zeigwort("LDR ",3);zeigzahl(sonne,4);} if (progy >= 6) {progy=0;} } void lesesensibel(){ if ((analogRead(LDR)/5) >= sonne) { sonne++;} if ((analogRead(LDR)/5) < sonne) { sonne--;} if ((analogRead(tMOS)/5) >= IRF) { IRF++;} if ((analogRead(tMOS)/5) < IRF) { IRF--;} if ((analogRead(tALU)/5) >= ALU) { ALU++;} if ((analogRead(tALU)/5) < ALU) { ALU--;} if ((analogRead(tSTEP)/5) >= STEP){ STEP++;} if ((analogRead(tSTEP)/5) < STEP){ STEP--;} if ((analogRead(tLED)/5) >= LED) { LED++;} if ((analogRead(tLED)/5) < LED) { LED--;} //if (LED <500 && ALU <490) {turbine=round((LED-330)*(fansens/10));} else {turbine=800;}//core+slu 330 kalt, alu 500 hot core } void istinput(void){ if (zeit1 >=1) { if (digitalRead(t1) == HIGH && onpress[0] ==0) { onpress[0] =1; progy++;} 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; tnenset=true; } if (onpress[2] == 1) { onpress[3]++;} if (onpress[3] >= 20) { onpress[3] =0; onpress[2]=0; } if (digitalRead(t3) == HIGH && onpress[4] ==0) { onpress[4] =1; tplusset=true; } 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; tminusset=true; } 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; } if (onpress[8] == 1) { onpress[9]++;} if (onpress[9] >= 10) { onpress[9] =0; onpress[8]=0; } zeit1=0; if (digitalRead(t5) == HIGH){digitalWrite(rstart, HIGH);}else {digitalWrite(rstart, LOW);} }} long timez= millis(); void zeitreise(void){ while ((millis()- maintime) >= 10) { zeit1++; lesesensibel(); maintime = millis(); } while ((micros()- maintime2) >= 400) { maintime2 = micros(); } while ((millis()- timez) >= 980) { timez = millis(); } } 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]);}} if (daa ==3) {for (byte ix3 = 0; ix3 < 4; ix3++){display.sendChar (ix3+8, outzi[ix3]);}} if (daa ==4) {for (byte ix4 = 0; ix4 < 4; ix4++){display.sendChar (ix4+12, outzi[ix4]);}} 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]);}} if (hier == 3){for (int iq3 = 0; iq3 < 4; iq3++){display.sendChar (iq3+8, woortz[iq3]);}} if (hier == 4){for (int iq4 = 0; iq4 < 4; iq4++){display.sendChar (iq4+12, woortz[iq4]);}} woortz=""; } void undlos(String meows) { // for print string to MAX 8dig display for (int i = 0; i < 16; i++){ display.sendChar (i, meows[i]); } } long sunriger=micros(); void machlicht(void) { while ((micros()-sunriger) >= 2) { for (int32_t fcount2=2; fcount2 <(2401); fcount2++) { if (fcount2 == ((2400)-lamp)) { digitalWrite(white, HIGH );} if (fcount2 == ((2400)-turbine)) { digitalWrite(fan, HIGH );} if (fcount2 >= 2399) { digitalWrite(white, LOW );digitalWrite(fan, LOW );}} sunriger= micros(); }}