#include #include #define LED_PIN 3 #define NUM_LEDS 9 #define STARLONG 5 int colorcode = 255 / STARLONG; CRGB leds[NUM_LEDS]; RCSwitch mySwitch = RCSwitch(); //int Program = 0; //int maxProgram = 2; //int Num = 0; //int Run = 0; //int Program0Delay = 100; //int Program1Delay = 100; //int Program2Delay = 10; //unsigned long DelayTime = 0; //bool Active = false; int anicolor = 255; int anispeed = 50; #define beyaz 1 #define farkli 0 boolean renk = farkli; 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) { case 9458954: mySwitch.disableReceive();//kırmızı Serial.println("kırmızı"); anicolor = 255; renk = farkli; break; case 9458955: mySwitch.disableReceive();//yesil Serial.println("yesil"); anicolor = 190; renk = farkli; break; case 9458956: mySwitch.disableReceive();//mavi Serial.println("mavi"); anicolor = 90; renk = farkli; break; case 9458957: mySwitch.disableReceive(); //sarı Serial.println("sarı"); anicolor = 210; renk = farkli; break; case 9458958: mySwitch.disableReceive(); //turuncu Serial.println("turuncu"); anicolor = 210; renk = farkli; break; case 9458959: mySwitch.disableReceive(); //turuncu Serial.println("turuncu--2"); anicolor = 230; renk = farkli; break; case 9458960: mySwitch.disableReceive(); // Serial.println("----1111"); anicolor = 220; renk = farkli; break; case 9458961: mySwitch.disableReceive(); //mavi Serial.println("mavi"); anicolor = 110; renk = farkli; break; case 9458962: mySwitch.disableReceive(); // Serial.println("----2222"); anicolor = 130; renk = farkli; break; case 9458963: mySwitch.disableReceive(); //pembe Serial.println("pembe"); anicolor = 75; renk = farkli; break; case 9458964: mySwitch.disableReceive(); //yesil Serial.println("yesil"); renk = farkli; anicolor = 170; break; case 9458965: mySwitch.disableReceive(); //beyaz olmalı Serial.println("beyaz"); //anicolor = 0; renk = beyaz; break; case 9458948: mySwitch.disableReceive(); Serial.print("hız++: "); if (anispeed <= 500) { anispeed += 100; } Serial.println(anispeed); break; 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; } Serial.println(anispeed); break; } mySwitch.resetAvailable(); mySwitch.enableReceive(0); } } void loop() { /* if (mySwitch.available()) { editcolor(); unsigned long int num = mySwitch.getReceivedValue(); Serial.println("Gelen Deger:" + String(num)); mySwitch.resetAvailable(); mySwitch.enableReceive(0); } */ // for (int a = 0; a < 5; a++) { //burada animasyon for (int w = 0; w <= 9; w++) { //int w = 5; if (renk == beyaz) { for (int s = 0; s <= STARLONG; s++) { leds[w + s].setRGB(colorcode * s, colorcode * s, colorcode * s); // leds[w - 1].setRGB(0, 0, 0); // leds[w + 0].setRGB(45, 45, 45); // leds[w + 1].setRGB(65, 65, 65); // leds[w + 2].setRGB(95, 95, 95); // leds[w + 3].setRGB(255, 255, 255); } } else { for (int s = 0; s <= STARLONG; s++) { leds[s + w] = CHSV(anicolor, colorcode * s, colorcode * s); // leds[w - 1] = CHSV(0, 0, 0); // leds[w + 0] = CHSV(anicolor, 45, 45); // leds[w + 1] = CHSV(anicolor, 65, 65); // leds[w + 2] = CHSV(anicolor, 95, 95); // leds[w + 3] = CHSV(anicolor, 175, 175); } } //delay(anispeed); unsigned long baslangic_sure = millis() + anispeed;//250; while (millis() <= baslangic_sure) { /* if (mySwitch.available()) { editcolor(); unsigned long int num = mySwitch.getReceivedValue(); Serial.println("Gelen Deger:" + String(num)); mySwitch.resetAvailable(); mySwitch.enableReceive(0); } */ editcolor(); } //Serial.print("for: "); //Serial.println(w); FastLED.show(); } //edittime(); Serial.print("anispeed: "); Serial.println(anispeed); Serial.flush(); //delay(anispeed); unsigned long baslangic_sure1 = millis() + anispeed; while (millis() <= baslangic_sure1) { /* if (mySwitch.available()) { editcolor(); unsigned long int num = mySwitch.getReceivedValue(); Serial.println("Gelen Deger:" + String(num)); mySwitch.resetAvailable(); mySwitch.enableReceive(0); }*/ editcolor(); } // FastLED.show(); //} }