//Simple programm RGB fire imitating HIGH power led device //\/ pindefinitionen/belegung #define rot PB13 //stripe oben grun *2meter 120x5050 RGB LEDs #define grun PB12 //tripe oben grun *2meter 120x5050 RGB LEDs #define blau PB14 //tripe oben grun *2meter 120x5050 RGB LEDs #define rot1 PA8 //tripe oben grun *2meter 120x5050 RGB LEDs #define grun1 PB15 //tripe oben grun *2meter 120x5050 RGB LEDs #define blau1 PB11 //tripe oben grun *2meter 120x5050 RGB LEDs #define rot2 PA5 //kontroll led grun *5mm bedienfront RGB LEDs #define grun2 PA6 //kontroll led grun *5mm bedienfront RGB LEDs #define blau2 PA7 //kontroll led grun *5mm bedienfront RGB LEDs #define potio PA1 //drehknopf oben (farbe/speed) #define potiu PA0 //drehknopf unten helligkeit #define change PA2 //drehknopf unten helligkeit //\/zwischenspeicherwerte int duty[10]; long allfcount = micros(); long maintime = millis(); int RGB =0; int light =401; int lights =0; int darkness =0; int zufall[8][4]; int fcount1 =0; int fcount2 =0; int zeit1 =0; int zeit2 =0; int zeit3 =0; int zeit4 =0; int zeit5 =0; int zeit6 =0; int stasi =0; int mainspeed=20; int oftblitz=5; //0kein, 1000nur) int difid =200; int modus=0; boolean wusch=false; void setup() { pinMode(rot, OUTPUT); pinMode(grun, OUTPUT); pinMode(blau, OUTPUT); pinMode(rot1, OUTPUT); pinMode(grun1, OUTPUT); pinMode(blau1, OUTPUT); pinMode(rot2, OUTPUT); pinMode(grun2, OUTPUT); pinMode(blau2, OUTPUT); pinMode(change, INPUT); } void loop() { wenntaster(); nottohigh(); rgbcalc(); machlicht(); } void wenntaster(void){ //drehknopfbetätigung if (zeit5 > 300) { if (modus==0 && RGB < (analogRead(potio)/2) ) {RGB+=2; } if (modus==0 && RGB > (analogRead(potio)/2) ) {RGB-=2; } if (digitalRead(change) == HIGH) {modus=1;} if (digitalRead(change) == LOW) {modus=0;} zeit5=0;} if (modus ==1 && zeit1 > 1 ) {RGB+=analogRead(potio)/200+1; stasi=20; lights =500; zeit1 =0; } } void nottohigh(void){ //nicht zwingend nötig if (zeit1 > 1000) {zeit1=0;} if (zeit2 > 1000) {zeit2=0;} if (zeit3 > 1000) {zeit3=0;} if (zeit4 > 1000) {zeit4=0;} if (zeit5 > 1000) {zeit5=0;} if (zeit6 > 1000) {zeit6=0;} } void rgbcalc(void) { //berechnet farben if (light >= 400) {darkness =0; lights = light -400;} if (light <= 399) {darkness =399 -light; lights =0;} if(RGB >=0 && RGB <=400) {duty[0] =400 -darkness; duty[1] =RGB + lights; duty[2] =0 + lights;} //rot ->gelb (rotmax grün+ blau0) if(RGB >=401 && RGB <=801) {duty[0] =(400 -(RGB -401)) +lights; duty[1] =400 -darkness; duty[2] =0 +lights;} //gelb ->grün (rot- grünmax blau0) if(RGB >=802 && RGB <=1202) {duty[0] =0+lights; duty[1] =400 -darkness; duty[2] =(RGB - 802) + lights;} //grün ->cyan (rot0 grünmax blau+) if(RGB >=1203 && RGB <=1603) {duty[0] =0+lights; duty[1] =(400 -(RGB - 1203)) +lights; duty[2] =400 -darkness;} //cyan ->blau (rot0 grün- blaumax) if(RGB >=1604 && RGB <=2004) {duty[0] =(RGB-1604) +lights; duty[1] =0 +lights; duty[2] =400 -darkness;} //blau ->lila (rot+ grün0 blaumax) if(RGB >=2005 && RGB <=2405) {duty[0] =400 -darkness; duty[1] =0+lights; duty[2] =(400- (RGB -2006)) +lights;} //lila ->rot (rotmax grün0 blau-) if(RGB >= 2406) {RGB =0;} duty[3]=duty[0]; duty[4]=duty[1]; duty[5]=duty[2]; } void machlicht(void) { //schaltet leds while ((micros()-allfcount) >= 1) { fcount1++; if (fcount1 == (401-duty[0])) { digitalWrite(rot, HIGH );} if (fcount1 == (401-duty[1])) { digitalWrite(grun, HIGH );} if (fcount1 == (401-duty[2])) { digitalWrite(blau, HIGH );} if (fcount1 == (402-duty[3])) { digitalWrite(rot1, HIGH ); digitalWrite(rot2, HIGH );} if (fcount1 == (402-duty[4])) { digitalWrite(grun1, HIGH ); digitalWrite(grun2, HIGH );} if (fcount1 == (402-duty[5])) { digitalWrite(blau1, HIGH ); digitalWrite(blau2, HIGH );} if (fcount1 >= 410 ) { digitalWrite(rot, LOW ); digitalWrite(grun, LOW ); digitalWrite(blau, LOW ); digitalWrite(rot1, LOW ); digitalWrite(grun1, LOW ); digitalWrite(blau1, LOW ); digitalWrite(rot2, LOW ); digitalWrite(grun2, LOW ); digitalWrite(blau2, LOW ); } if (fcount1 > (analogRead(potiu)/5+410)) { fcount1 = 0; zeit1++; zeit2++; } zeit5++; zeit4++;zeit3++; zeit6++; allfcount = micros(); } } //just simple little thingi vor controlling a RGB stripe in rainbowcolors (actually all 3 RGB outputs show the same color) /*MEOW! It's marderchens code mess and FREEEEE use it or parts if you want! * * ___ __ ___ ______ ____ _ __ ___ / _/ / |/ / / ____/ / __ \| | / / / / / / / /|_/ / / __/ / / / /| | /| / / / / / / / / / / / /___ / /_/ / | |/ |/ / / / / / /_/ /_/ /_____/ \____/ |__/|__/ _/ / /__/ /__/ ___ //| / _ \ |/|| _____ / // / /____/ _ _ _ \___/ _ /____/ ( )( )( ) (_) |/ |/ |/ */