/* created by marderchen =^.^= RGB thinking .. random is nice, but need some controll RED, GREEN, BLUE, YELLOW, CYAN, MAGENTA rot grün blau rot gelb grün cyan blau lila 100 110 010 011 001 101 duty1 0-150 duty2 0 duty3 0 -> duty1 0-150 duty2 0-150 duty3 0 -> duty1 0 duty2 0-150 duty3 0 -> duty1 0 duty2 0-150 duty3 0-150 -> duty1 0 duty2 0 duty3 0-150 -> duty1 0-150 duty2 0 duty3 0-150 RGB = ?; (150 stufen je farbe rreichen mir.. = schneller) ist nur die basis ohne eigenständige varbveränderung have to change a little for good funktion *update its running fine now */ //umsetzung programmstart\/ int lights =0; int darlness =0; int RGB =0; // 0-905 (rainbowspectrum linear 905steps) int light =150; //(int have no comma..) 150 = no changes _ 300=white(rainbow spectrum +white) _ 0 = (rainbowspectrum +dark) void rgbcalc(void) { if (light >= 150) {darkness =0; lights = light - 150;} if (light <= 149) {darkness =150 - light; lights =0;} if(RGB >=0 && RGB <=150) {duty1 =150 -darkness; duty2 =RGB + lights; duty3 =0 + lights;} //rot ->gelb (rotmax grün+ blau0) if(RGB >=151 && RGB <=301) {duty1 =150 -(RGB -151) +lights; duty2 =150 -darkness; duty3 =0 +lights;} //gelb ->grün (rot- grünmax blau0) if(RGB >=302 && RGB <=452) {duty1 =0+lights; duty2 =150 -darkness; duty3 =(RGB - 302) + lights;} //grün ->cyan (rot0 grünmax blau+) if(RGB >=453 && RGB <=603) {duty1 =0+lights; duty2 =150 -(RGB - 453) +lights; duty3 =150 -darkness;} //cyan ->blau (rot0 grün- blaumax) if(RGB >=604 && RGB <=754) {duty1 =(RGB-604) +lights; duty2 =0 +lights; duty3 =150 -darkness;} //blau ->lila (rot+ grün0 blaumax) if(RGB >=755 && RGB <=905) {duty1 =150 -darkness; duty2 =0+lights; duty3 =150- (RGB -756) +lights;} //lila ->rot (rotmax grün0 blau-) if(RGB >= 906) {RGB=0;} } void setlights(void){ while ((micros()-allfcount) >= 10) { fcount1++; if (fcount1 == (151-duty1)) { digitalWrite(rot, HIGH );} if (fcount1 == (151-duty2)) { digitalWrite(grun, HIGH );} if (fcount1 == (151-duty3)) { digitalWrite(blau, HIGH );} if (fcount1 >= 153) {digitalWrite(rot, LOW ); digitalWrite(blau, LOW ); digitalWrite(grun, LOW ); fcount1 = 0;} // rainbowt++; //automatic rainbow.. need: int rainbowt=0; //if (rainbowt >=300) { RGB++; rgbcalc(); rainbowt=0; } //automatic rainbow.. need: int rainbowt=0; allfcount = micros(); }} //------------ umsetzungprogrammende für mich-- rest ist schon drin.. //this duty cyclus dont work with something like adafruit gfz used durring fading collors.. coused systemslowdown /* //angeschlossen and digitaloutputs vom STM32F103C8T6 #define rot PA10 #define grun PA9 #define blau PA2 //\/im setup.. pinMode(blau, OUTPUT); pinMode(rot, OUTPUT); pinMode(grun, OUTPUT); ______________ } */