//Simple programm for fading 6 channels over bluetooth for the STM32 24x 3Watt UV led roomlight by marderchen =^.^= //bluetoothmodul: HC-06 RS232 connected over PB9 and PB10 without configuring //bluetoth transmiting to USB bluetooth stick settet to com port //currently controling with the freeware termite terminal by sending charactertext //wusel code by marderchen its free use it ot parts if its usefull for you #define UV_1 PB12 #define UV_2 PB13 #define UV_3 PB14 #define UV_4 PB15 #define UV_5 PB10 #define UV_6 PB11 #define notused1 PA8 //possible 4xUVwatt #define notused2 PA7 //possible 4xUVwatt //status #define rot PA6 #define grun PA4 #define blau PA5 int duty[11]; long allfcount = micros(); long stropos = micros(); long maintime = millis(); int glow[12]; int RGB =0; int light =400; int lights =0; int darkness =0; int weis =0; int modus =0; int uvges =0; int fcount1 =0; int fcount2 =0; int zeit1 =0; int zeit2 =0; String cach =""; String cachb =""; int wooo =0; int woooo=0; void setup() { pinMode(UV_1, OUTPUT); pinMode(UV_2, OUTPUT); pinMode(UV_3, OUTPUT); pinMode(UV_4, OUTPUT); pinMode(UV_5, OUTPUT); pinMode(UV_6, OUTPUT); pinMode(notused1, OUTPUT); pinMode(notused2, OUTPUT); pinMode(rot, OUTPUT); pinMode(grun, OUTPUT); pinMode(blau, OUTPUT); Serial1.begin(9600); } void loop() { askbluetooth(); zeitreise(); test(); rgbcalc(); machlicht(); } void askbluetooth(void) { while(Serial1.available()>0) { RGB+=1; // cach += Serial1.read(); int cachs = Serial1.read(); cachb = ""; cachb += (char)cachs; if (isDigit(cachs)) { cach += (char)cachs; } if ( cachb == "r") { uvges =cach.toInt(); for( int uv = 0; uv <6; uv++) { duty[uv] =uvges; } Serial1.print("=^.^= MEOW! setze gesamte UV helligkeit auf -> "); Serial1.print(uvges); Serial1.print(" <- \n"); cach =""; cachb =""; } if ( cachb == "s") { duty[wooo] = cach.toInt(); cach =""; cachb =""; wooo++; } if ( cachb == "z") { Serial1.print("=^.^= MEOW! setze UV helligkeiten -> "); for( int das = 1; das <7; das++) { Serial1.print("ch"); Serial1.print(das); Serial1.print("=> "); Serial1.print(duty[das-1]); Serial1.print(" "); } Serial1.print("\n"); wooo=0; cachb =""; } if ( cachb == "f") { glow[woooo] = cach.toInt(); cach =""; cachb =""; woooo++; } if ( cachb == "g") { Serial1.print("=^.^= MEOW! setze UV autofading -> speed+=> "); Serial1.print(glow[0]); Serial1.print(" speed-=> "); Serial1.print(glow[1]); Serial1.print(" max=> "); Serial1.print(glow[2]); Serial1.print(" min=> "); Serial1.print(glow[4]); Serial1.print("\n"); glow[5]=1; cachb =""; woooo=0; } if ( cachb == "a") { glow[5]++; if (glow[5] == 1){ Serial1.print("=^.^= MEOW! started UV autofading"); } if (glow[5] == 2){ Serial1.print("=^.^= MEOW! stoped UV autofading"); glow[5]=0; } cachb =""; } if ( cachb == "i") { Serial1.print("=^.^= MEOW! I am The 75Watt UV led roomlight \n \n"); Serial1.print("=^.^= MEOW! better not look inside my LEDs \n"); Serial1.print("=^.^= MEOW! I calculate with 72Mhz STM32TF1038T6 \n"); Serial1.print("=^.^= MEOW! I transmit with 9600baud bluetooth \n"); Serial1.print("=^.^= MEOW! I have 128kB FLASH and 20kB RAM \n"); Serial1.print("=^.^= MEOW! I my supplys 19V 4.75A, 4.5V 0.55A\n"); Serial1.print("=^.^= MEOW! I am switching 24x 3W UV LEDs on 6channels\n"); Serial1.print("=^.^= MEOW! I am codet with Arduino IDE \n"); Serial1.print("=^.^= MEOW! code and pictures from my inside on \n"); Serial1.print("=^.^= MEOW! thinking must be somwhere there:: \n"); Serial1.print("=^.^= MEOW! http://marderchen.de or www.marderchen.de \n"); Serial1.print("=^.^= MEOW! my developer is marderchen \n \n"); cachb =""; } }} void zeitreise(void){ while ((millis()- maintime) >= 3) { zeit1++; maintime = millis(); } } void test(void){ if (zeit1 > 5) {lights =600; RGB+=3; zeit1 =0;} if (glow[5] == 1){ // updownauto fader if (zeit2 > glow[0] && glow[6] == 0) {uvges++; zeit2 =0;} if (zeit2 > glow[1] && glow[6] == 1) {uvges--; zeit2 =0;} for( int uv = 0; uv <6; uv++) { duty[uv] =uvges; } // uebernehme dutywert dür alle 6 kanaele if (uvges >= glow[2]) { glow[6] =1;} if (uvges <= glow[3]) { glow[6] =0;} } } void rgbcalc(void) { if (light >= 400) {darkness =0; lights = light -400;} if (light <= 399) {darkness =399 -light; lights =0;} if(RGB >=0 && RGB <=400) {duty[6] =400 -darkness; duty[7] =RGB + lights; duty[8] =0 + lights;} //rot ->gelb (rotmax grün+ blau0) if(RGB >=401 && RGB <=801) {duty[6] =(400 -(RGB -401)) +lights; duty[7] =400 -darkness; duty[8] =0 +lights;} //gelb ->grün (rot- grünmax blau0) if(RGB >=802 && RGB <=1202) {duty[6] =0+lights; duty[7] =400 -darkness; duty[8] =(RGB - 802) + lights;} //grün ->cyan (rot0 grünmax blau+) if(RGB >=1203 && RGB <=1603) {duty[6] =0+lights; duty[7] =(400 -(RGB - 1203)) +lights; duty[8] =400 -darkness;} //cyan ->blau (rot0 grün- blaumax) if(RGB >=1604 && RGB <=2004) {duty[6] =(RGB-1604) +lights; duty[7] =0 +lights; duty[8] =400 -darkness;} //blau ->lila (rot+ grün0 blaumax) if(RGB >=2005 && RGB <=2405) {duty[6] =400 -darkness; duty[7] =0+lights; duty[8] =(400- (RGB -2006)) +lights;} //lila ->rot (rotmax grün0 blau-) if(RGB >= 2406) {RGB =0;} } void machlicht(void) { while ((micros()-allfcount) >= 2) { fcount1++; if (fcount1 == (401-duty[0])) { digitalWrite(UV_1, HIGH );} if (fcount1 == (401-duty[1])) { digitalWrite(UV_2, HIGH );} if (fcount1 == (401-duty[2])) { digitalWrite(UV_3, HIGH );} if (fcount1 == (401-duty[3])) { digitalWrite(UV_4, HIGH );} if (fcount1 == (401-duty[4])) { digitalWrite(UV_5, HIGH );} if (fcount1 == (401-duty[5])) { digitalWrite(UV_6, HIGH );} if (fcount1 == (401-duty[6])) { digitalWrite(rot, HIGH );} if (fcount1 == (401-duty[7])) { digitalWrite(grun, HIGH );} if (fcount1 == (401-duty[8])) { digitalWrite(blau, HIGH );} if (fcount1 == (401-duty[9])) { digitalWrite(notused1, HIGH );} if (fcount1 == (401-duty[10])) { digitalWrite(notused2, HIGH );} if (fcount1 >= 405 ) { digitalWrite(UV_1, LOW ); digitalWrite(UV_2, LOW ); digitalWrite(UV_3, LOW ); digitalWrite(UV_4, LOW ); digitalWrite(UV_5, LOW ); digitalWrite(UV_6, LOW ); digitalWrite(rot, LOW ); digitalWrite(grun, LOW ); digitalWrite(blau, LOW ); digitalWrite(notused1, LOW ); digitalWrite(notused2, LOW ); fcount1 = 0; zeit2++; } allfcount = micros(); } } /* * ___ __ ___ ______ ____ _ __ ___ / _/ / |/ / / ____/ / __ \| | / / / / / / / /|_/ / / __/ / / / /| | /| / / / / / / / / / / / /___ / /_/ / | |/ |/ / / / / / /_/ /_/ /_____/ \____/ |__/|__/ _/ / /__/ /__/ ___ //| / _ \ |/|| _____ / // / /____/ _ _ _ \___/ _ /____/ ( )( )( ) (_) |/ |/ |/ */ */