Using Red-Green-Blue (RGB) LEDs with Arduino (Common Cathode Type)

Поділитися
Вставка
  • Опубліковано 27 жов 2024

КОМЕНТАРІ • 60

  • @jimmyzhao2673
    @jimmyzhao2673 Рік тому +2

    I love LEDs. a fantastic invention.

  • @Cyberplayer5
    @Cyberplayer5 5 років тому +2

    If you input the analog input to the red led and input the inverse value to the blue led you can control the HUE like a NTSC TV does.

  • @kshitijgupta2156
    @kshitijgupta2156 4 роки тому +3

    // Using RGB Led With Three Potensiometer
    int Red = 3;
    int Green = 5;
    int Blue = 6;
    int R_potensiometer = A0;
    int G_potensiometer = A1;
    int B_potensiometer = A2;
    void setup()
    {
    pinMode(Red, OUTPUT);
    pinMode(Green, OUTPUT);
    pinMode(Blue, OUTPUT);

    pinMode(R_potensiometer, INPUT);
    pinMode(G_potensiometer, INPUT);
    pinMode(B_potensiometer, INPUT);
    }
    void loop()
    {
    int Input_Colour_Red = analogRead(R_potensiometer);
    int Input_Colour_Green = analogRead(G_potensiometer);
    int Input_Colour_Blue = analogRead(B_potensiometer);
    Input_Colour_Red = map(Input_Colour_Red, 0, 1023, 0, 255);
    Input_Colour_Green = map(Input_Colour_Green, 0, 1023, 0, 255);
    Input_Colour_Blue = map(Input_Colour_Blue, 0, 1023, 0, 255);

    analogWrite(Red, Input_Colour_Red);
    analogWrite(Green, Input_Colour_Green);
    analogWrite(Blue, Input_Colour_Blue);
    // Delay A Bit For Better Performence
    delay(10);
    }
    This is the code for using RGB led through 3 potensiometer

  • @JerryEricsson
    @JerryEricsson 8 років тому

    Nice, what amazes me is that there are so few who click the like/dislike buttons, I would think this would be a very popular subject to learn about, and this set of tutorials are just wonderful. I am using arduinos in my regular day to day live, and have combined this device with my HAM hobby as the two go together like a bride and groom.

  • @dominiquecave8
    @dominiquecave8 7 місяців тому

    This is such a great tutorial. Thank you!

  • @occamsrayzor
    @occamsrayzor 6 років тому +1

    I love this! Clearly and concisely explained, using examples all the way. Subscribed.

  • @abenwinUT
    @abenwinUT 6 років тому +1

    Excellent video, very informative. Thanks for taking the time and effort to post it.

  • @mitchellconley9338
    @mitchellconley9338 6 років тому +3

    I would definitely recommend adding an annotation to add resistors at the setup stage. I think I smoked my RGB.

  • @stephen6640
    @stephen6640 Рік тому

    Well done!

  • @mdatiqunnabi5729
    @mdatiqunnabi5729 9 років тому +2

    excellent work. tutorials are very well organized.

  • @robertbuckley3762
    @robertbuckley3762 5 років тому

    Nice, I learned the map() function! Very cool, thanks.

  • @WhoWantsToKnow81
    @WhoWantsToKnow81 9 років тому +1

    Love your tutorials. Subbed!

    • @programmingelectronics
      @programmingelectronics  9 років тому

      WhoWantsToKnow81 Thanks a ton for watching!

    • @WhoWantsToKnow81
      @WhoWantsToKnow81 8 років тому +1

      +Harrison Huff I wouldn't willingly die knowing that your English is absolutely atrocious

  • @PeteVree
    @PeteVree 5 років тому

    If you are using a Common Anode RGB, you'll have to connect the VCC to +5V. The values of each are messed up as well...
    0 = Full Brightness
    255 = Off
    Here is a link to values for various colours using the Common Anode: learn.sparkfun.com/tutorials/lilypad-tri-color-led-hookup-guide/all

    • @PeteVree
      @PeteVree 5 років тому

      For the beginning portion, Michael has us turn on the Red, Green and Blue sequentially. If you have the Common Anode, just do the opposite... turn it LOW... then turn it HIGH.

  • @JohnL90808
    @JohnL90808 8 років тому +1

    To get equal amounts of light from each color, I think a proper resistor value is necessary. Red requires 2 volts, its resistor should be 150 ohms, green and blue needs 3.3 volts so their resistors should be 100 ohms. If the resistor values are correct, you should get a whitish blend which doesn't lean to any of the colors.
    I don't want to comment about your program writing style, but it's not necessary to be too verbose with your variables, it's an efficient practice to use short but meaningful names on your variables and to always start with a lowercase letter as it's considered clean format. Also it's memory-efficient to use the #define preprocessor for your pin assignments. The int data type is very wasteful.

    • @CurmudgeonExtraordinaire
      @CurmudgeonExtraordinaire 5 років тому +1

      I'm a retired engineer and have worked for NASA and various DoD and aerospace contractors. One standard that we used was to use a lowercase first letter for variables that have scope local to a function or for functions that are not supposed to be publicly visible. Variables that start with uppercase letters were global variables. Functions that start with uppercase letters were visible to other modules. There were also other conventions like making each module have a unique identifier (usually 3-5 uppercase characters followed by an underscore) that you would put on any function that was visible and designed to be used by other modules. These were very large projects where you might have hundreds of developers working on various parts of it across numerous teams at various companies. It's a good practice even if you are working on smaller projects, because if you do it right, it helps in the reuse of code. Write it once... Debug it once... Reuse it many times... Writing the same code over and over is boring...

    • @bernym4047
      @bernym4047 Рік тому

      @@CurmudgeonExtraordinaire Thanks for that very sound advice. 😀

  • @nextstorming3908
    @nextstorming3908 8 років тому +2

    Subscribed after 3 videos, they're helpful AF

  • @fardinheidari5787
    @fardinheidari5787 3 роки тому

    thanks a lot. so useful and perfect explanations

  • @snaprollinpitts
    @snaprollinpitts 10 років тому +2

    thanks Michael, I wanted to know how to use those things, and I just happen to have one. thanks mike/doogie

  • @simonhopkins3867
    @simonhopkins3867 9 років тому +1

    excellent tutorials I think I can see the light. :)

  • @futurebotz4470
    @futurebotz4470 3 роки тому

    My RGB led is not giving out the exact RED,BLUE and GREEN colors when I give the intensity as required. The output is more of yellow,purple and blue. Can someone help me on this?

  • @bibolonton321
    @bibolonton321 10 років тому

    really appreciate your great work, sir. I prefer yours to Jeremy Blum

    • @exoticblood4665
      @exoticblood4665 8 років тому

      +bibolonton JEREMY BLUM IS MY FUCKING LIFE! HOW DARE YOU DISRESPECT HIM YOU UNINTELLEGENT PIECE OF TRASH

    • @itszombies7256
      @itszombies7256 4 роки тому

      @@exoticblood4665 lol

  • @Abirhanchate7482
    @Abirhanchate7482 Рік тому +1

    I love your voice

  • @andymouse
    @andymouse 8 років тому

    nice work can you explain a simple wireless set up with those cheap RX, TX parts I think they are about 433mhz ? or have I just confused the hell out of you ? if its the latter ....sorry!

  • @jumbo999614
    @jumbo999614 5 років тому +2

    What is the amount of ohms of the resistors you used for this set up?
    also, how do you find out if RGB Led has Common Cathode or Anode?

    • @MrAlfredodlh2
      @MrAlfredodlh2 3 роки тому +1

      330ohm

    • @شيماءالملاح-ع3ب
      @شيماءالملاح-ع3ب 3 роки тому +1

      By avo, red wire on comman pin and black to any pin another
      If the led turn on, that mean it is a common anode, If not, that is mean it is comman cathode!

  • @ZetkoCZ60
    @ZetkoCZ60 8 років тому

    Why do you have that LED connected with resistors ?

  • @LumitheHedgehog
    @LumitheHedgehog 10 років тому +1

    Open Source Hardware Group Thanks for the link but ... Now I cant find COM3 and i checked it and it says that its working fine. (P.s. This is the fastest ive ever typed)

  • @superstark8543
    @superstark8543 7 років тому

    What about common anode type RGBs. How can use them?

  • @kishoreysn7801
    @kishoreysn7801 6 років тому

    How to control many such rgb common cathode leds with limited number of arduino pins.

    • @HentaiNat
      @HentaiNat 6 років тому

      KISHORE YSN shift registers.

  • @jimelektriek4852
    @jimelektriek4852 10 років тому +1

    on 3:43 drawing you're not using any resistor and suddenly on the real 'thing' (6:50) i see three resistors .... somthing wrong with your setup ?

    • @programmingelectronics
      @programmingelectronics  10 років тому

      Dooht! Yikes - the drawing at 3:43 is incorrect. Needs to have 3 220 OHM resistors attached from the pins to the RGB leads...Thanks for pointing that out Jim! I may just pull the video and reload a correct one, or make an annotation in there.

    • @jimelektriek4852
      @jimelektriek4852 10 років тому +1

      Open Source Hardware Group ur welcome! Forgot to mention i like your vid's a lot !

    • @Shakespeare1612
      @Shakespeare1612 9 років тому +1

      jim elektriek
      Are you sure that using the same resistor values for each LED is the best idea. According to the Ebay common cathode RGB LEDs that I got, the red LED operates at a typical voltage of 2.4 volts, and the green and blue like to operate at 3.4 volts. This circuit shows a 150 ohm resistor on the red, and 100 ohm resistors on the green and blue. This would tend to make the PWM values in your code MEAN the same thing for all three LED colors, would it not?
      i.stack.imgur.com/egSqx.png

    • @jimelektriek4852
      @jimelektriek4852 8 років тому

      ?? hate ?? huh

    • @mattlidd9504
      @mattlidd9504 7 років тому

      yeah.. I tried it with wires but figured it out

  • @hajrasiddiqui684
    @hajrasiddiqui684 8 років тому

    is map function already builtin or you create it ?? in which tutorial have you taught about map function ????

  • @NibblyBitz
    @NibblyBitz 7 років тому

    Programming Electronics Academy
    I am wanting to control my difused rgb led with my pc but the problem I am having is if it is a common cathode or a common anode led. How do I tell and if I can't will it hurt trying ground pin and then trying 5v to see which one works?

    • @MyBigThing2010
      @MyBigThing2010 7 років тому

      NibblyBitz get a multimeter...connect the long leg to red lead and one of the short ones to black...if it lights it's common anode...if it doesn't then reverse your leads, if it lights when black is on the long one then it's common cathode....multimeter should be on the diode test setting

    • @MyBigThing2010
      @MyBigThing2010 7 років тому

      DON'T put 5V directly on any LED without a resistor in line somewhere. .you WILL fry it

  • @livelifezippo8250
    @livelifezippo8250 8 років тому +1

    Hello friend, I just want to say first great videos. I'm just a little confused with this one, on the schematic you didn't show to put any resistors and you say that the long end of the pin of the led is the cathode but in the setup it looks like the cathode is pined into the positive rail of the breadboard, I'm confused and I keep getting and error when I try to verify the work.

  • @CodeWithSwarnim
    @CodeWithSwarnim 6 років тому

    i need the whole code please

  • @neerajmaurya2
    @neerajmaurya2 5 років тому

    made itt

  • @rajeshtorash8933
    @rajeshtorash8933 6 років тому

    Sir How to program pixel led with Atmega328

  • @annadenaro9919
    @annadenaro9919 5 років тому

    //Using an RGB (common Cathode)
    //pin variables
    int Pin_LED_Red = 3;
    int Pin_LED_Green = 5;
    int Pin_LED_Blue = 6;
    void setup() {
    // set the mode of the pins
    pinMode(Pin_LED_Red, OUTPUT);
    pinMode(Pin_LED_Green, OUTPUT);
    pinMode(PIN_LED_Blue, OUTPUT);
    }
    void loop() {
    //turn on and off led
    digitalWrite(Pin_LED_Red, HIGH);
    delay(500);
    digitalWrite(Pin_LED_Red,LOW);
    //turn on and off led
    digitalWrite(Pin_LED_Green, HIGH);
    delay(500);
    digitalWrite(Pin_LED_Green,LOW);
    //turn on and off led
    digitalWrite(Pin_LED_Blue, HIGH);
    delay(500);
    digitalWrite(Pin_LED_Blue,LOW);
    }
    "Pin_LED_Blue" was not declared in this scope. what am I doing wrong?

    • @annadenaro9919
      @annadenaro9919 5 років тому

      bI have re-wrote it out, I've tried all your codes in this video and the all say Pin_LED _Blue was not declared in this scope.

    • @SwatinJOSH
      @SwatinJOSH Рік тому +1

      idk if you even care about this program anymore but if you haven't figured it out yet, you have an uppercase "I" on your tenth line lol
      hope this helped :)