#087

  Рет қаралды 5,731

The Sales Engineer

The Sales Engineer

7 жыл бұрын

Common Anode RGB LEDs
2 solutions for working with them, one via logic, and the other via transistors. See which is your favorite...
Source (sketches):
Logic: atcp.us/arduino/RGB-LED_CommAn...
NPNs: atcp.us/arduino/RGB-LED_CommAn...
I show example circuits, a little theory, draw up the example circuits, then show them running.
Some folks make good arguments as to why CA is preferable, but in the case of an MCU which produces 'source' instead of 'sink', ... you decide!

Пікірлер: 41
@samdeur
@samdeur 2 жыл бұрын
i'm a 46yr Unix / Linux sysadmin decided to go back to school this fall and doing a bachelor in tech covering C# , C and C++ knowing this stuff is also part of the curriculum and important..was searching for the diff between Cathode vs Anode because of the Elegoo kit i just got seems to have 2 Comm Cathode RGB-LED everything turns on with my multi-meter except blue i think it has to do with the power i'm providing with my multi-meter in continuity mode or lack of power i think.. But your explanation of this is great.. I wanted to thank you for this.. i'm going to buy a pack of both led's to see if i can get it to work and fully understand what your explaining here..$2 for a pack of 10 form Aliexpress sounds like a great deal for a good lesson..i'm also subscribing. Chanels like yours are the reason i got KZbin Premium membership ;-) Thanks again greetings from The Netherlands.
@pattheitguy
@pattheitguy 2 жыл бұрын
Wow! Your story is very inspiring. I am in my '60s and have completed lots of credits toward a computer science degree, but after I started my own company 5 years ago, there has been absolutely zero time. I need to spend more time on these videos, and the videos under my other channel called The IT Guys.
@reefmaster
@reefmaster 5 жыл бұрын
Helped a lot. Searching through forums, people make it too confusing, but you explain it very well. Subbed.
@appu5545
@appu5545 2 жыл бұрын
that's cool...I brought common anode and struggled a bit longer...you are a rescuer
@NoGoodNames4Me2
@NoGoodNames4Me2 6 жыл бұрын
Okay, so your video is a bit lengthy, but hell - you're really good at explaining stuff and making sure everyone can follow! *You just earned a new sub* :)
@tonyvarghese75
@tonyvarghese75 5 жыл бұрын
Po
@roberthatcher2773
@roberthatcher2773 4 жыл бұрын
Thanks, great stuff, I bought common anodes by mistake, so you helped me out, good explanations.
@anthonybarton4252
@anthonybarton4252 8 ай бұрын
Excellent video. Thank you. That was very helpful.
@salc9593
@salc9593 6 жыл бұрын
Thanks for posting this video... I received a number of Common Anode RGB Leds and did know how to deal with this issue. I am new to Arduino and this allows me to continue with my project... I would like to know what is the difference between the 2N222 and the 2N3904 Transistor which you used. Thank you again for help this old dog learn a new trick :-)
@TheSalesEngineer
@TheSalesEngineer 6 жыл бұрын
@Sal C, thanks for writing! The 2N2222 is able ot handle higher voltage & current, but not much more than the 2N3904... Check out the datasheets for both to see what I mean... As for cost, they are in everyone's price range: cheap :) 2N3904 datasheet: www.onsemi.com/pub/Collateral/2N3903-D.PDF @100 pcs, $0.0121 ea. 2N2222 datasheet: www.onsemi.com/pub/Collateral/P2N2222A-D.PDF @100 pcs, $0.0099 ea. Gadgetry is a very affordable hobby/profession!
@salc9593
@salc9593 6 жыл бұрын
Thank you for the information and the Data Sheets on both of the Transistors. I am looking forward to viewing your other videos. Thank you again.
@tyrian869
@tyrian869 Жыл бұрын
What if say I had the WS2811 NeoPixel LED Driver Chip that is Anode led support only, and the custom LED RGB switch I ordered was common cathode type is there any way to make a circuit using similar components that would make it so I could use this LED driver?
@poepflater
@poepflater 3 жыл бұрын
Which circuit would draw more power?
@chbonnici
@chbonnici 6 жыл бұрын
Please can you give us the full code using the invertColor system just for experience. Thank you
@TheSalesEngineer
@TheSalesEngineer 6 жыл бұрын
Done.
@bogus_not_me
@bogus_not_me 5 жыл бұрын
Thanks! you did help a lot - and you're right - most of the other youtubers do NOT have it right! I'm looking at both the Logic and the NPN, but I don't have 2N3904. All I have is 8050, which is also an NPN, so would that work also? I do have one of those rare things - a RBG led - that's right, red blue green. It's also diffused, so light is less of a glare. I had to test three pieces before I found the CC. Is there another way to tell them apart? One last - can you show the connections of each more clearly? It's hard tp see with so many screens running, and like you said one wire wrong and it burns something out.
@TheSalesEngineer
@TheSalesEngineer 5 жыл бұрын
Any NPN would work, as we're using it as a switch. So as long as you have volts to saturate it, current will flow. I've learned over the years to get xistors that need 5 or less volts, so they will always work on battery powered projects, but you might be using different voltages. Next, you ask about the common. RGB LEDs are very common, and I have several hundred. It's harder to find them in 3mm and smaller, but they exist. Commons are almost always the longest pin. The datasheet is best if it isn't obvious. An ET spends half their time in datasheets! 😊 To your question about telling them apart, no need to blow them up. Toss a resistor on a 1.5v batt, or dial your bench supply way down. They are just diodes, after all, so as long as you stay below reverse bias Max, you're good. start at .25v to try to get a color to light, trying diff pin cfgs, and bump a .25v at a time. You will find that most often, red will illuminate first. Your last point confused me. Show the wiring? I drew the schematic on paper with a marker as I explained it. Try drawing your schematic as well, and compute vdrops at each to start. When I was in electronics vo-tech, 3hours each day, we weren't allowed to make any circuits until a thorough drawing (hand-drawn schematic) was shown, with current through each component, voltage drops for each, and calculated wattage dissipated by each component. It may seem stupid today, but we were taught that we couldn't afford good components, so our parents would not appreciate the bill from the school if we fucked up. And back then, even though calculators were coming out, only slide rules were allowed. So yeah, it is useful to draw your schematics, if you ask me. 😀
@bogus_not_me
@bogus_not_me 5 жыл бұрын
@@TheSalesEngineer I have spent a lot of time looking at datasheets and pinouts, so I was glad to see that is normal. The S8050 shows Max 6V so I'm good there. My problem is building a circuit from a schematic, but I'm getting better at figuring it out. I have tried drawing a schematic from the components I want to use, but it's hard. I'm thinking I need 3 S8050 to make the CA RGB work. G the CC RGB I mentioned is actually a red-blue-green, NOT red-green-blue. Disconnected both outside leads, and the only one left was blue! I think I'm getting better at this, and have a lot of things to do. Bought an elegoo 37 sensors kit, and they have a small CD with diagrams and code that automatically loads to the àrduino IDE. Lots of fun to come. I really appreciate your response - so many KZbinrs do not respond, and I need help. I'm a 77 year old retired accountant that seats wanted to learn more electronics. You are helping! and I appreciate it!
@TheSalesEngineer
@TheSalesEngineer 5 жыл бұрын
@@bogus_not_me oh! Now I see. I assumed that the way breadboards are wired was thoroughly known. If so, you could freeze the video and basically draw your own! All you need is a good example of how breadboards are wired, as almost everyone uses them to prototype these days. This is an awesome launching point: www.sciencebuddies.org/science-fair-projects/references/how-to-use-a-breadboard I am not that far behind you in age, BTW. I learned with tubes. Mr. Lehr my first electronics instructor had many sayings I remember, like, "To tell if a tube is bad-drop it. If it breaks, it was good!". I tell stories about back then in the videos to fill the more boring parts. I went to something unheard of today-soldering school. An entire year before there was SMD. After that was military as an ET, and we had to trace every single wire in a system via schematics (and tested) before we could even look at it. I didn't grow up in a disposable world, and neither did you. Our Legos weren't "kits", and you couldn't Google something. This is the crime of modern education, which is funded by grades instead of knowledge. Kids don't know how to think. They only know how to look something up. We had to take a pile of crap and achieve an objective, using creative thinking, imagination, and no safety net. Plainly, kids today are stupid because they were never taught how to figure something out. Sad, really.
@bogus_not_me
@bogus_not_me 5 жыл бұрын
@@TheSalesEngineer I once built a 25"color TV from a kit from Bell & Howell, It was part of my vet benefits. They would not ship the components to build it until I passed six soldering tests to their satisfaction. Both surface mount and through hole, And tested it to make sure nothing was shorted. The TV worked for several years and if something went wrong I knew how to fix it. That was in 74 or 75. Until now, that was the last time I did anything electronic. Do you have any plans on how to build a component that works externally and communicates with the computer or Arduino? Can't see getting an Àrduino for every sensor I might build - maybe a mini or micro. I'm thinking of maybe externally temp/humidity mounted outside that I could read from inside. Haven't seen anyone do that yet. Email? Mine is cfanglin42@twc.com.
@TheSalesEngineer
@TheSalesEngineer 5 жыл бұрын
Look for Me. Carlson's Lab here on KZbin!
@TubistFromTexas
@TubistFromTexas 7 жыл бұрын
What of you wanted to put these common anode led in series, how would you go about that?
@BogusException
@BogusException 7 жыл бұрын
Irving Blanco ... Well, 2 things tho think about-maybe more. Series or parallel, each led segment (red, green, and blue) still has the same voltage & current requirements. Because the resistor to drop the voltage & current from supply is in series, you'd only need one. But there is a problem with this theory, and it has to do with the "common" part. All 3 leds in an rgb go through a common point (in this case +, or anode). So if you apply Vcc to the first rgb led's anode, which led's catbode on that first led would you connect rgb led #2's anode to? One little led in rgb#2 would have all the current drawn by rgb#2 going through it. Worse yet, the current through that one led in rgb#1 would affect ALL 3 leds in rgb#2. I use HC595 chips To control lots of leds. Why would you want to put them in serial? Is there a use case, or are you asking academically/theoretically?
@TheSalesEngineer
@TheSalesEngineer 6 жыл бұрын
Consider the humble shift register (learn.adafruit.com/adafruit-arduino-lesson-4-eight-leds/overview) like the mighty 74HC595... Since you can't put LEDs in serial (why would you need to even try?), these let you go crazy with just a single MCU output pin! :)
@kevingamon8599
@kevingamon8599 4 жыл бұрын
I’m probably commenting on the wrong video, but I’d like to find out how to connect about 10, 5mm rgb leds and have them all turn on together. No special patterns but would like to have the freedom of switching between colors through a remote or even an app. Any suggestions or help?
@PatTrainor
@PatTrainor 4 жыл бұрын
Kevin, The method is the same-unless you want 10 running independently. I can't tell from what you wrote, but you say both that you want them able to turn on all at once, or switching between colors. What matters is whether you are talking about 10xRGBs, or 10x individual color LEDs. If you are talking about 10xRGBs, then it is all about current. IOW, what is the total draw of all 10 at once? Here is one of hundreds of articles about how RGBs work: os.mbed.com/users/4180_1/notebook/rgb-leds/ Because an RGB is actually 3 LEDs, you need to be careful. Most importantly, each of the LEDs has different voltage and current requirements/maximums. If you put them all in parallel, your issue will be more of total current draw than voltage-but you must feed all the Rs, Gs, and Bs the sabe. That leaves you with 3 channels, with 10x the amount of current needed than for a single LED. So at the top I said it was all about current. In this video, I show how common Anode or Cathode makes no difference, and show both. But I am also using a small, generic transistor to do the switching on & off (and dimming). You will still need 3 transistors, but you MUST make sure each of the 3 you use (for R, G, and B), can handle the total MAX amount of current that all 10 LEDs will need/draw. So, if you have discovered that the red LEDs in your RBG LED take 18ma each, you need a switch/transistor that can handle at least 180ma (plus safety margin). This is too much current than a single digital out pin off a microcontroller can supply, which is why I use transistors. But you might want something manual, and use physical switches. So the "iffy" part of all of this depends on how you plan to change the colors/dimming of ear leg of the RGB LEDs. Hope this gets you in the right direction, and if my assumptions about what little you gave me are right, then you are, ni fact, on the right video.
@TheSalesEngineer
@TheSalesEngineer 6 жыл бұрын
Here is the sketch on the left: int redPin = 9; int greenPin = 6; int bluePin = 5; int delayChange = 5; // in ms, how long to delay each loop of brightness change int loopDelta = 1; // how much to change brightness each loop int ledLow = 0; // lowest value for each LED int ledHigh = 200; // highest value for each color void setup() { Serial.begin(115200); pinMode(redPin, OUTPUT); pinMode(greenPin, OUTPUT); pinMode(bluePin, OUTPUT); setColor(0, 0, 0); randomSeed(analogRead(0)); } void loop() { int rRed = (int)random(ledLow,ledHigh); int rGreen = (int)random(ledLow,ledHigh); int rBlue = (int)random(ledLow,ledHigh); Serial.println("rRed: " + String(rRed) + " rGreen: " + String(rGreen) + " rBlue: " + String(rBlue)); // fade up (brighter) for (int c = 0; c < 255; c += loopDelta) { float fc = float(c) / 255.0; int r = (int)(fc * rRed); int g = (int)(fc * rGreen); int b = (int)(fc * rBlue); setColor(r, g, b); delay(delayChange); // without some delay, it flashes REALLY fast } // fade down (darker) for (int c = 255; c > 0; c -= loopDelta) { float fc = float(c) / 255.0; int r = (int)(fc * rRed); int g = (int)(fc * rGreen); int b = (int)(fc * rBlue); setColor(r, g, b); delay(delayChange); } } /** * Just easier to call like this */ void setColor(int redValue, int greenValue, int blueValue) { analogWrite(redPin, invertColor(redValue)); analogWrite(greenPin, invertColor(greenValue)); analogWrite(bluePin, invertColor(blueValue)); } /** * The joys of common anode RGB LEDs! */ int invertColor(int color) { return (color * -1) + 255; }
@GunwantBhambra
@GunwantBhambra 6 жыл бұрын
i just cut the common anode on top to separate them to 6 pins from 4 and it works!!
@TheSalesEngineer
@TheSalesEngineer 6 жыл бұрын
GBranade I don't understand. How did you separate them?
@GunwantBhambra
@GunwantBhambra 6 жыл бұрын
The Sales Engineer this was original ibb.co/i2wOVp And i cut the joint and then on they worked as individual leds ibb.co/jjSK39
@GunwantBhambra
@GunwantBhambra 6 жыл бұрын
The Sales Engineer i see i bought a chip and you bought a bulb im dumb but thnks for video will use the info for a bulb then
@TheSalesEngineer
@TheSalesEngineer 6 жыл бұрын
That was where you lost me! Pretty nice that they let you do either!
@chbonnici
@chbonnici 6 жыл бұрын
Sorry,I would like to connect the leds common Anode
@TheSalesEngineer
@TheSalesEngineer 6 жыл бұрын
Here is the sketch on the right: int redPin = 9; int greenPin = 6; int bluePin = 5; int delayChange = 5; // in ms, how long to delay each loop of brightness change int loopDelta = 1; // how much to change brightness each loop int ledLow = 0; // lowest value for each LED int ledHigh = 200; // highest value for each color void setup() { Serial.begin(115200); pinMode(redPin, OUTPUT); pinMode(greenPin, OUTPUT); pinMode(bluePin, OUTPUT); setColor(0, 0, 0); randomSeed(analogRead(0)); } void loop() { int rRed = (int)random(ledLow,ledHigh); int rGreen = (int)random(ledLow,ledHigh); int rBlue = (int)random(ledLow,ledHigh); Serial.println("rRed: " + String(rRed) + " rGreen: " + String(rGreen) + " rBlue: " + String(rBlue)); // fade up (brighter) for (int c = 0; c < 255; c += loopDelta) { float fc = float(c) / 255.0; int r = (int)(fc * rRed); int g = (int)(fc * rGreen); int b = (int)(fc * rBlue); setColor(r, g, b); delay(delayChange); // without some delay, it flashes REALLY fast } // fade down (darker) for (int c = 255; c > 0; c -= loopDelta) { float fc = float(c) / 255.0; int r = (int)(fc * rRed); int g = (int)(fc * rGreen); int b = (int)(fc * rBlue); setColor(r, g, b); delay(delayChange); } } /** * Just easier to call like this */ void setColor(int redValue, int greenValue, int blueValue) { analogWrite(redPin, redValue); analogWrite(greenPin, greenValue); analogWrite(bluePin, blueValue); } Enjoy!
@chbonnici
@chbonnici 6 жыл бұрын
I would d like to make a chaser lights say 5 channel connected led common cathod . How will I modify the code using your invertColour code int invertColor(int color) { return (color * -1) + 255; // Works OK connect leds common cathode //Define Leds int L1=2; int L2=3; int L3=4; int L4=5; int L5=6; //Define Timeings int d1=200; //d1 = delay time high int d2=0; //d2 = delay time Low void setup(){ pinMode(2, OUTPUT); pinMode(3, OUTPUT); pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); } void loop(){ analogWrite(L1,255); delay(d1); analogWrite(L1,0); delay(d2); analogWrite(L2,255); delay(d1); analogWrite(L2,0); delay(d2); analogWrite(L3,255); delay(d1); analogWrite(L3,0); delay(d2); analogWrite(L4,255); delay(d1); analogWrite(L4,0); delay(d2); analogWrite(L5,255); delay(d1); analogWrite(L5,0); delay(d2); }
@TheSalesEngineer
@TheSalesEngineer 6 жыл бұрын
Well, if you just want (on an 8-bit uC) to control with low=dim, high=bright, then each time you specify a value (above you use 0 and 255, but any value between will work), then you replace the: analogWrite(Lx,255) ...with: analogWrite(Lx, invertColor(255)); with invertColor() being: int invertColor(int color) { return (color * -1) + 255; } This way, even if you don't want to use 255 (maybe 245, or better yet, adjustable by user, program or sensor), the function works as expected. In fact, I would suggest you use a single variable for your analogWrite() intensity values, so all you need to do is vary that one variable to make ALL your LEDs dim or brighten-all without interfering with the 'chasing'... I hope this all helps!
@TheSalesEngineer
@TheSalesEngineer 6 жыл бұрын
Also, you should consider a cheap shift register. It doesn't take up the pins like your example does, and they are insanely expandable! examples: -74HC595 the standard! @100 pcs, $0.0344 each! -Use just ONE pin to control 8 LEDs at once: learn.adafruit.com/adafruit-arduino-lesson-4-eight-leds/overview ...and don't forget you can daisy-chain them! :)
RGB LEDs with Arduino - Standard & NeoPixel
43:35
DroneBot Workshop
Рет қаралды 128 М.
How an RGB LED works and how to use one! | Basic Electronics
7:00
CircuitBread
Рет қаралды 200 М.
Задержи дыхание дольше всех!
00:42
Аришнев
Рет қаралды 3,8 МЛН
Каха заблудился в горах
00:57
К-Media
Рет қаралды 10 МЛН
НРАВИТСЯ ЭТОТ ФОРМАТ??
00:37
МЯТНАЯ ФАНТА
Рет қаралды 8 МЛН
Атака ВСУ на Курскую область: что происходит?
24:16
BBC News - Русская служба
Рет қаралды 428 М.
How Do Computers Remember?
19:32
Sebastian Lague
Рет қаралды 6 МЛН
#093 ESP-01 ESP8266 Relay Module Modification (FIX!)
1:40:03
The Sales Engineer
Рет қаралды 21 М.
LED Circuit Design - How to design LED circuits
21:44
The Engineering Mindset
Рет қаралды 1,8 МЛН
HOW TO USE WS2812B NEOPIXELS WITH FASTLED ON ARDUINO
24:32
Gadget Reboot
Рет қаралды 180 М.
#088 The Cheap XL830L Multimeter!
52:55
The Sales Engineer
Рет қаралды 3,2 М.
Controlling high power (or a high number of) LED's with an Arduino
8:08
The Custom Geek
Рет қаралды 171 М.
Stop, Intel’s Already Dead!
13:47
Linus Tech Tips
Рет қаралды 583 М.
Control RGB LEDs with Arduino || Arduino Essentials #1
4:23
Nerdforge
Рет қаралды 664 М.
How To Control WS2812B Individually Addressable LEDs using Arduino
9:31
How To Mechatronics
Рет қаралды 1,1 МЛН
Son ❤️ #shorts by Leisi Show
0:41
Leisi Show
Рет қаралды 8 МЛН
Проверил, как вам?
1:00
Коннор
Рет қаралды 19 МЛН
Yung Relax Kalang sa Paghuli #fishingtechniques #cambodia #amazing
0:21
Читерская рыбалка!🤯🐟 (@fishinglover790)
0:24
Взрывная История
Рет қаралды 2,8 МЛН