//rainbow rectagle mirror reflector 10Watt RGB handspot driver progressn //MEOW its free use it or parts is usefull :3 #define t1 PA15 #define t2 PA12 #define t3 PB15 #define t4 PA8 #define rotm PB14 #define grunm PB13 #define blaum PB12 #define power PA2 #define tastmeld PA1 #define LDR PA0 #define rot PC13 #define grun PC15 #define blau PC14 int8_t onpress[10]; int duty[10]; long maintime=millis(); long maintime2=micros(); int zeit1,zeit2,zeit3,zeit4,zeit5,sonne; int16_t rainbow; int16_t bright =300; void setup() { pinMode(rot, OUTPUT); pinMode(grun, OUTPUT); pinMode(blau, OUTPUT); pinMode(rotm, OUTPUT); pinMode(grunm, OUTPUT); pinMode(blaum, OUTPUT); pinMode(power, OUTPUT); pinMode(tastmeld, OUTPUT); pinMode(t1, INPUT); pinMode(t2, INPUT); pinMode(t3, INPUT); pinMode(t4, INPUT); } int progy=0; void loop() { zeitreise(); if (analogRead(LDR) >= sonne) { sonne++;} if (analogRead(LDR) < sonne) { sonne--;} if (progy == 0) {autocolor(); rainbowcalc(); } if (progy == 1) {rainbowcalc(); } if (progy == 2) { progy=0;} istinput(); machlicht(); } int16_t brightc,brightcc,nenrandy,rainc; void autocolor(void){ if (zeit5 >200) { rainc=random(0,5);zeit5=random(0,150);} if (zeit2 >rainc) {rainbow++; zeit2=0;} if (zeit3 >600 || (bright-1) <= brightc || (bright+1) >= brightc) {nenrandy=random(0,25); if (nenrandy <5) { brightc=random(20,350); brightcc=random(1,5); } if (nenrandy >= 5 && nenrandy <20) {brightc=random(100,410); brightcc=random(2,7); } if (nenrandy >= 20 ) { brightc=random(400,800); brightcc=random(1,5); } } if(zeit4 > brightcc) { if (bright > brightc) {bright--;} if (bright < brightc) {bright++;}zeit4=0;} } void istinput(void){ if (zeit1 >=2) { if (digitalRead(t1) == HIGH && onpress[0] ==0) { onpress[0] =1; progy++;} if (onpress[0] == 1) { onpress[1]++; duty[6]= onpress[1]*20; } if (onpress[1] >= 20) { onpress[1] =0; onpress[0]=0; } if (digitalRead(t2) == HIGH && onpress[2] ==0) { onpress[2] =1; rainbow=0; bright-=20;} 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; bright+=20; } if (onpress[4] == 1) { onpress[5]++;} if (onpress[5] >= 20) { onpress[5] =0; onpress[4]=0; } if (digitalRead(t4) == HIGH && onpress[6] ==0) { onpress[6] =1; rainbow-=240;} if (onpress[6] == 1) { onpress[7]++;} if (onpress[7] >= 20) { onpress[7] =0; onpress[6]=0; } if (onpress[1] >1 || onpress[3] >1 || onpress[5] >1 || onpress[7] >1) { duty[4]=400;} if (duty[4] > 2) {duty[4]-=10;} zeit1=0; }} void zeitreise(void){ while ((millis()- maintime) >= 3) { zeit1++; zeit3++; zeit5++; maintime = millis(); } while ((micros()- maintime2) >= 200) { zeit2++; zeit4++; maintime2 = 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;} } long startriger=micros(); int32_t light,darkness,dcach; void machlicht(void) { if (bright > 400){light=bright-400; darkness=0;} if (bright <=400){darkness=(400-(bright)); light=0;} while ((micros()-startriger) >= 2) { for (int32_t fcount1=0; fcount1 <(800); fcount1++) { if (fcount1 == ((401+darkness)-duty[0])) { digitalWrite(rot, HIGH );} if (fcount1 == ((401+darkness)-duty[1])) { digitalWrite(grun, HIGH );} if (fcount1 == ((401+darkness)-duty[2])) { digitalWrite(blau, HIGH );} if (fcount1 == ((401+darkness)-duty[3])) { digitalWrite(power, HIGH );} if (fcount1 == ((401+darkness)-duty[4])) { digitalWrite(rotm, HIGH );} if (fcount1 == ((401+darkness)-duty[5])) { digitalWrite(grunm, HIGH );} if (fcount1 == ((401+darkness)-duty[6])) { digitalWrite(blaum, HIGH );} if (fcount1 >= (402 + light) ) { digitalWrite(rot, LOW ); digitalWrite(grun, LOW ); digitalWrite(blau, LOW ); digitalWrite(power, LOW ); digitalWrite(rotm, LOW ); digitalWrite(grunm, LOW ); digitalWrite(blaum, LOW ); }} startriger = micros(); } } //hihi basicly changed little in my polarsterndriver =^.^=