Arduino/Elegoo - How to make an RGB LED fade through all the colors

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 พ.ค. 2024
  • Continuing our tutorials on LEDs and Arduino, we continue using RGB LED's and introduce for loops to make the LED fade through all of the different possible colors to make. You can then take what you've learned in this tutorial to make any custom color or pattern you would like! We use the UNO R3 board, (3) 1K resistors, and a RGB LED with common cathode.
    Instagram: @quick_tech_tutorials
    Please check out my other tutorials on other tech related platforms. Thanks for watching and make sure to subscribe to be notified for future tutorial videos!

ความคิดเห็น • 39

  • @mantasrauba8036
    @mantasrauba8036 3 ปีที่แล้ว +34

    those who are really lazy to write here the good stuff. (tbh smth i missed out or what but its not really smooth fading) Heres the codes cuz he didnt post it
    int red = 2;
    int green = 4;
    int blue = 5;
    void setup() {
    pinMode(red, OUTPUT);
    pinMode(green, OUTPUT);
    pinMode(blue, OUTPUT);
    digitalWrite(red, HIGH);
    digitalWrite(green, LOW);
    digitalWrite(blue, LOW);
    }
    int redValue;
    int greenValue;
    int blueValue;
    void loop()
    {
    #define delayTime 10
    for(int i = 0; i < 255; i += 1)
    {
    redValue -= 1;
    greenValue+= 1;
    analogWrite(red, redValue);
    analogWrite(green, greenValue);
    delay(delayTime);
    }
    redValue = 0;
    greenValue= 255;
    blueValue=0;
    for(int i = 0; i < 255; i += 1)
    {
    greenValue -= 1;
    blueValue += 1;
    analogWrite(green, greenValue);
    analogWrite(blue, blueValue);
    delay(delayTime);
    }
    redValue = 0;
    greenValue= 0;
    blueValue=255;
    for(int i = 0; i < 255; i += 1)
    {
    blueValue -= 1;
    redValue += 1;
    analogWrite(blue, blueValue);
    analogWrite(red, redValue);
    delay(delayTime);
    }
    }

    • @quicktechtutorials7289
      @quicktechtutorials7289  3 ปีที่แล้ว +3

      While that's nice of you to post the lines of code, doesn't really teach anybody anything if they just copy and paste it. If you're having trouble with your LED fading, rewatch the video and type in the code that I have and you shouldn't have any issues.

    • @mantasrauba8036
      @mantasrauba8036 3 ปีที่แล้ว +3

      ye i did everything the same, after that changed some things but ye maybe my arduino is kinda bugging out cuz when i was making VU meter it did everything opposite even tho everything was right.

    • @nhuvlog1127
      @nhuvlog1127 3 ปีที่แล้ว +2

      @@quicktechtutorials7289 I tried to follow ur steps but I keep getting errors even tho I looked at it 10 times. haha!! thank god Mantas Rauba saved me

    • @IzzmeAz
      @IzzmeAz 3 ปีที่แล้ว

      The code is working properly. I only changed the delay time to 15 and the digital pins to 11, 10, 9. Thnx!

    • @samuelmuentes
      @samuelmuentes 2 ปีที่แล้ว

      A true MVP.

  • @dwtya5038
    @dwtya5038 3 ปีที่แล้ว +2

    Nice video, and good explanation! Keep it up!

  • @plugnugget3672
    @plugnugget3672 ปีที่แล้ว

    Absolutly fantastic video - I love the confidence in your presentation. You've really got something going here - keep on it mate ;)

  • @josehernandezcalderon278
    @josehernandezcalderon278 2 ปีที่แล้ว +1

    After 1 day searching, i find the solution, thanks!

  • @MrBobWareham
    @MrBobWareham ปีที่แล้ว

    Very good video, thank you for explaining the code and how it works, I want to add a button to have other effects can you please do a video on adding a button, thanks.

  • @omaradel6384
    @omaradel6384 3 ปีที่แล้ว +2

    Thank you ❤️❤️

  • @mixgamer2908
    @mixgamer2908 3 ปีที่แล้ว +8

    good but code? can you give us? pls

  • @rselectronic9377
    @rselectronic9377 3 ปีที่แล้ว +1

    Nice

  • @michaeldeloso9042
    @michaeldeloso9042 2 หลายเดือนก่อน

    Good day Sir 👋
    How to setup code for my 4pin led rgb module in which the led fast changing colors blinks in accordance to the speed of music beat or noise and automatically turns to super slow changing color mode when there is no music or noise detected on the surroundings?

  • @Greenslimegaming11181
    @Greenslimegaming11181 3 ปีที่แล้ว +4

    can you add a schematic?

  • @lxrrxxnnxxii1849
    @lxrrxxnnxxii1849 2 ปีที่แล้ว

    Can you make this with other different colors?

  • @hhhqqq3918
    @hhhqqq3918 3 ปีที่แล้ว

    nice

  • @virendersingh6027
    @virendersingh6027 2 ปีที่แล้ว

    Please make fade in out video on ws2812 rgb 60 led strip.
    Thanks

    • @quicktechtutorials7289
      @quicktechtutorials7289  2 ปีที่แล้ว

      Sorry I don't have those parts at the moment but I plan on making a video on how to control LED strips with Arduino.

  • @cezarmihnea
    @cezarmihnea ปีที่แล้ว +1

    I sort of fixed the smoothness by setting the delay time to 20 but it still jumps from green to blue kinda aggressively, any fix?

    • @quicktechtutorials7289
      @quicktechtutorials7289  ปีที่แล้ว

      I would need to see your program before I can offer a suggestion. Would you mind pasting your program?

    • @cezarmihnea
      @cezarmihnea ปีที่แล้ว

      @@quicktechtutorials7289 it's the same that mantas posted below, but the delay is 20.

    • @quicktechtutorials7289
      @quicktechtutorials7289  ปีที่แล้ว +2

      @@cezarmihnea It looks to be the digital pins you are using. I just rebuilt the circuit and used pins 3, 5 & 6 and used mantas program and it works fine for me. Try connecting the red pin to pin 3, green to 5, and blue to 6 and make sure to change that at the beginning of your program. I also pasted a program that I tested and works. Let me know if that helps
      int red=3;
      int green=5;
      int blue=6;

      void setup() {
      pinMode(red, OUTPUT);
      pinMode(green, OUTPUT);
      pinMode(blue, OUTPUT);

      digitalWrite(red, HIGH);
      digitalWrite(green, LOW);
      digitalWrite(blue, LOW);

      }
      //define variables
      int redvalue;
      int greenvalue;
      int bluevalue;
      void loop(){
      // put your main code here, to run repeatedly:
      #define delayTime 20 //fading time between colors
      for(int i = 0; i

    • @cezarmihnea
      @cezarmihnea ปีที่แล้ว

      @@quicktechtutorials7289 Wow! Thanks a lot. I will try it.

  • @wahyupans8868
    @wahyupans8868 3 ปีที่แล้ว +1

    Wht if we add some another led effect? What's code can be?

    • @necromancer8251
      @necromancer8251 3 ปีที่แล้ว +1

      i just sodered another led onto the same wire

  • @shekharpanagar7467
    @shekharpanagar7467 ปีที่แล้ว

    please give your code link in the discription

  • @daveblackstudios2254
    @daveblackstudios2254 3 ปีที่แล้ว +1

    helped thxx

  • @luiisxz6886
    @luiisxz6886 3 ปีที่แล้ว +3

    code???

  • @raymondmichael4987
    @raymondmichael4987 ปีที่แล้ว

    But this is blocking, how to run it without blocking the loop

  • @fredymiljohngentapa8553
    @fredymiljohngentapa8553 3 ปีที่แล้ว

    Can I ask for the code?

  • @shantibhaipatel513
    @shantibhaipatel513 2 ปีที่แล้ว +1

    can you make this without Arduino ?

    • @quicktechtutorials7289
      @quicktechtutorials7289  2 ปีที่แล้ว

      While it doesn't have to be Arduino specifically, you would need some type of microcontroller and board or an IC chip that you can program and build into the LED circuit