#include #include #include #define LED_PIN 3 #define NUM_LEDS 20 #define BRIGHTNESS 255 #define SATURATION 255 int STARLONG = 10; int part1h = 9; int part1f = 0; int part2h = 19; int part2f = 10; int partfullh = 19; int partfullf = 0; int parthead = part1h; int partfoot = part1f; int closehead = part2h; int closefoot = part2f; int colorcode = 255 / STARLONG; //int progvalue = 0; //int farkli = 0; CRGB leds[NUM_LEDS + 5]; RCSwitch mySwitch = RCSwitch(); int anicolor = 255; int anispeed = 100; int anispeed0 = 100; int anispeed1 = 100; int anispeed2 = 3; int anispeed3 = 3; int anispeed4 = 100; int anispeed5 = 3; int anispeed6 = 1; int ekstra_parlaklik = 50; int progvalue = 1; int farkli = 0; int degerwht = 0; int renk = progvalue; int R, G, B; void setup() { FastLED.addLeds(leds, NUM_LEDS); FastLED.setMaxPowerInVoltsAndMilliamps(12, 500); FastLED.clear(); FastLED.show(); //FastLED.addLeds(Strip1, Num_Strip1); Serial.begin(9600); mySwitch.enableReceive(0); // Receiver on interrupt 0 => that is pin #2 } //bu da renk ve hız ayarları void editcolor() { if (mySwitch.available()) { unsigned long int num = mySwitch.getReceivedValue(); Serial.println("Gelen Kod: " + String(num)); Serial.print("Gelen Renk: "); switch (num) { // 9458945 306177 case 9458945: mySwitch.disableReceive();//aç Serial.println("aç"); parthead = part1h; partfoot = part1f; closehead = part2h; closefoot = part2f; progvalue = 1; break; // 9458947 306179 case 9458947: mySwitch.disableReceive();//kapat Serial.println("kapat"); anicolor = 255; progvalue = 0; R = 0; G = 0; B = 0; break; // 9458954 306186 case 9458954: mySwitch.disableReceive();//kırmızı Serial.println("kırmızı"); anicolor = 255; progvalue = 0; R = 255; G = 0; B = 0; break; case 306187: mySwitch.disableReceive();//yesil Serial.println("yesil"); anicolor = 190; renk = farkli; R = 0; G = 255; B = 0; break; case 306188: mySwitch.disableReceive();//mavi Serial.println("mavi"); anicolor = 90; renk = farkli; R = 0; G = 0; B = 255; break; case 306189: mySwitch.disableReceive(); //sarı Serial.println("sarı"); anicolor = 210; renk = farkli; R = 255; G = 255; B = 0; //////////// break; case 3061890: mySwitch.disableReceive(); //turuncu Serial.println("turuncu"); anicolor = 210; renk = farkli; R = 255; G = 153; B = 51; break; case 306191: mySwitch.disableReceive(); //turuncu Serial.println("turuncu--2"); anicolor = 230; renk = farkli; R = 255; G = 128; B = 0; break; case 306192: mySwitch.disableReceive(); // Bu hangi renk Serial.println("----1111"); anicolor = 220; renk = farkli; R = 255; G = 50; B = 0; break; case 306193: mySwitch.disableReceive(); //mavi Serial.println("mavi"); anicolor = 110; renk = farkli; R = 0; G = 0; B = 204; break; case 306194: mySwitch.disableReceive(); // Bu hangi renk Serial.println("lacivert"); anicolor = 130; renk = farkli; R = 0; G = 50; B = 255; break; case 306195: mySwitch.disableReceive(); //pembe Serial.println("pembe"); anicolor = 75; renk = farkli; R = 255; G = 0; B = 255; break; case 306196: mySwitch.disableReceive(); //yesil Serial.println("yesil"); renk = farkli; anicolor = 170; R = 51; G = 255; B = 51; break; case 306197: mySwitch.disableReceive(); //beyaz olmalı Serial.println("beyaz"); //anicolor = 0; renk = farkli; R = 255; G = 255; B = 255; break; // 9458948 306183 case 9458948: mySwitch.disableReceive(); Serial.print("hız++: "); if (anispeed <= 500) { anispeed += 100; } parthead = part1h; partfoot = part1f; closehead = part2h; closefoot = part2f; progvalue = 1; Serial.println(anispeed); break; // 9458951 306180 case 9458951: mySwitch.disableReceive(); Serial.print("hız--: "); if (anispeed >= 150) //Burası 150 olmalı çünkü 50 olduğu zaman içine girerse yeni değer -50 olur { anispeed -= 100; } parthead = part2h; partfoot = part2f; closehead = part1h; closefoot = part1f; progvalue = 2; Serial.println(anispeed); break; // bu ikisi //9458950 //artan //9458953 //azalan case 306185: mySwitch.disableReceive(); Serial.print("ekstra_parlaklik++: "); if (ekstra_parlaklik <= 500) { ekstra_parlaklik += 20; } Serial.println(ekstra_parlaklik); break; case 306182: mySwitch.disableReceive(); Serial.print("ekstra_parlaklik--: "); if (ekstra_parlaklik >= 20) { ekstra_parlaklik -= 20; } Serial.println(ekstra_parlaklik); break; // 9458949 306181 case 9458949: mySwitch.disableReceive(); Serial.print("ilk 10'lu "); parthead = part1h; partfoot = part1f; closehead = part2h; closefoot = part2f; progvalue = 5; Serial.println("açıldı"); break; // 9458952 306184 case 9458952: mySwitch.disableReceive(); Serial.print("ikinci 10'lu: "); parthead = part2h; partfoot = part2f; closehead = part1h; closefoot = part1f; progvalue = 6; Serial.println("açıldı"); break; case 306178: mySwitch.disableReceive(); Serial.print("20'si birden "); parthead = part2h; partfoot = part1f; closehead = 21; closefoot = 20; progvalue += 1 ; Serial.println("açıldı"); break; default: break; } mySwitch.resetAvailable(); mySwitch.enableReceive(0); } } void loop() { for (int k = partfoot; k <= parthead; k++) { leds[k].setRGB(0, 0, 0); } // if (progvalue >= 4) // { // progvalue = 1; // } for (int k = closefoot; k <= closehead; k++) { leds[k].setRGB(0, 0, 0); } Serial.println(progvalue); // 1. animasyon başla if (progvalue == 1) { Serial.println("kayan"); //1.ani leds[partfoot].setRGB(255, 255, 255); delay(anispeed1); leds[partfoot].setRGB(180, 180, 180); leds[partfoot + 1].setRGB(255, 255, 255); delay(anispeed1); leds[partfoot].setRGB(120, 120, 120); leds[partfoot + 1].setRGB(180, 180, 180); leds[partfoot + 2].setRGB(255, 255, 255); delay(anispeed1); FastLED.show(); for (int s = partfoot; s < parthead - 2; s++) { leds[s - 1].setRGB(0, 0, 0); leds[s + 0].setRGB(60, 60, 60); leds[s + 1].setRGB(120, 120, 120); leds[s + 2].setRGB(180, 180, 180); leds[s + 3].setRGB(255, 255, 255); delay(anispeed1); FastLED.show(); } leds[parthead - 3].setRGB(0, 0, 0); leds[parthead - 2].setRGB(60, 60, 60); leds[parthead - 1].setRGB(120, 120, 120); leds[parthead].setRGB(180, 180, 180); delay(anispeed1); FastLED.show(); leds[parthead - 2].setRGB(0, 0, 0); leds[parthead - 1].setRGB(60, 60, 60); leds[parthead].setRGB(120, 120, 120); delay(anispeed1); FastLED.show(); leds[parthead - 1].setRGB(0, 0, 0); leds[parthead].setRGB(60, 60, 60); delay(anispeed1); FastLED.show(); leds[parthead].setRGB(0, 0, 0); delay(anispeed1); FastLED.show(); } // 1. animasyon bitiş // 2. animasyon başla if (progvalue == 2) { Serial.println("parılda"); //3.ani degerwht = random(partfoot, parthead - 1); leds[degerwht - 1].setRGB(255, 255, 255); leds[degerwht].setRGB(0, 0, 0); leds[degerwht + 1].setRGB(255, 255, 255 ); delay(anispeed2); FastLED.show(); } // 2. animasyon bitiş // 3. animasyon başla if (progvalue == 3) { Serial.println("gokkusagi"); for (int j = 0; j < 255; j++) { for (int i = partfoot; i < parthead + 1; i++) { leds[i] = CHSV(i - (j * 2), SATURATION, BRIGHTNESS); delay(anispeed3); FastLED.show(); } } delay(anispeed); FastLED.show(); } // 3. bitiş // 4. animasyon başla if (progvalue == 4) { Serial.println("yanıp sol"); for (int w = 255; w > 5; w -= 5) { for (int d = parthead; d > partfoot - 1; d--) { leds[d].setRGB(w, w, w); delay(3); FastLED.show(); } } for (int w = 5; w < 255; w += 5) { for (int d = parthead; d > partfoot - 1; d--) { leds[d].setRGB(w, w, w); delay(3); FastLED.show(); } } delay(anispeed2); FastLED.show(); } // 4. animasyon bitiş if (progvalue == 5) //rastgele renk { //5.ani for (int d = 0; d < 5; d++) { degerwht = random(partfoot + 2, parthead - 1); leds[degerwht - 3].setRGB(255, 0, 0); leds[degerwht - 2].setRGB(255, 255, 0); leds[degerwht - 1].setRGB(0, 0, 255 ); leds[degerwht + 0].setRGB(0, 255, 0); leds[degerwht + 1].setRGB(255, 153, 51 ); leds[degerwht + 2].setRGB(255, 0, 255 ); delay(anispeed5); FastLED.show(); } //5.ani bit } if (progvalue == 6) //dalga { //6.ani for (int d = parthead; d > partfoot - 1; d--) { for (int w = 125; w > 5; w -= 5) { leds[d].setRGB(255 - w, 255 - w, 255 - w); delay(anispeed6); FastLED.show(); } delay(anispeed5); FastLED.show(); } for (int d = parthead; d > partfoot - 1; d--) { for (int w = 5; w < 125; w += 5) { leds[d].setRGB(255 - w, 255 - w, 255 - w); delay(anispeed6); FastLED.show(); } delay(anispeed5); FastLED.show(); } //6.ani bit } if (progvalue == 0) { //Serial.print("anicolor: "); //Serial.println(anicolor); for (int s = partfoot; s <= parthead; s++) { //leds[s + w] = CHSV(anicolor * s, colorcode * s, colorcode * s); //leds[w + s].setRGB(anicolor , anicolor * s, anicolor * s); Serial.print("R: "); Serial.println(R); Serial.print("G: "); Serial.println(G); Serial.print("B: "); Serial.println(B); leds[s].setRGB(R , G, B); } } // delay(10); FastLED.show(); Serial.print("anispeed: "); Serial.println(anispeed); Serial.flush(); unsigned long baslangic_sure1 = millis() + anispeed; while (millis() <= baslangic_sure1) { editcolor(); } }