![]() In the void setup(), we initialize all LEDs (in fact, the 3 legs of the RGB LED) to OUTPUT mode. One for the potentiometer, and one for each color of the LED – we write the code as if we were controlling 3 different LEDs. Setup RGB and potentiometer pins #define RGB_RED_PIN 11Īt first, as a best practice, we create a define for each pin we are going to use. Int mode = map(potentiometerValue, 0, 1023, 0, 6) Int potentiometerValue = analogRead(POTENTIOMETER_PIN) Void digitalWriteRGB(byte red, byte blue, byte green) We are going to use digitalWrite() – LED fully powered on/off, which means that we have a combination of 7 colors: You can see the RGB LED as a combination of 3 different LEDs that you control separately. In this first application, we are going to modify the color of the RGB LED when we turn the potentiometer knob. Connect the middle leg to an analog pin.Ĭontrol the RGB LED with the potentiometer – digitalWrite() – 7 colors.The other extreme leg should be connected to 5V on the Arduino. Connect one of the extreme leg (for example left) to the ground.Add a 220 Ohm resistor in between for each leg. Connect each of these legs to a PWM compatible digital pin on the Arduino (with a “~” next to the number, like on the picture). The 3 other legs correspond to red, blue, and green colors.If it’s an anode, plug it to 5V on the Arduino. So, if it’s a cathode, plug this to the ground (GND). If no instructions, you can first try the “cathode mode” and see if it works. How to find out? Simply check the manual or description of what you’ve bought. Depending on your RGB LED, this can be a cathode or an anode. Make a common ground by connecting a GND pin of the Arduino, to the “minus” line of the breadboard.You are learning how to use Arduino to build your own projects?Ĭheck out Arduino For Beginners and learn step by step. Arduino board – I use Arduino Uno, but any board where you have at least 3 PWM compatible digital pins, and one analog pin, is fine.Going further with the potentiometer and RGB LEDĪrduino circuit with RGB LED and potentiometer.Select a different color for each value.Control the RGB LED with potentiometer – analogWrite() – 1536 colors.Power on the RGB LED depending on the potentiometer’s value.Control the RGB LED with the potentiometer – digitalWrite() – 7 colors.Arduino circuit with RGB LED and potentiometer.These normally take 350mA, so look for a constant current circuit that can provide that. It looks like you just have five bare 1W LEDs. That specification looks to me like it was the specification of the whole finished lighting unit before it was pulled to bits. The eBay seller hasn't got a clue what he has got, he probable just picked up a batch of random junk and this was in it. What do you want to do with these LEDs? Are they for serious lighting? If so you are going to have to push a hell of a lot more current down them than 75mA. However that does not square up with the 110 to 220V input. From bits of a data sheet I have managed to find for a QX5252 it looks like it is a switching regulator. You could have done exactly the same as you are doing now with a NPN transistor or N channel FET.Īnyway that page says the device has a SMD 5252 Integrated Chip, not sure where but that is what it says. The other thing is why you think this is a common cathode LED? There is no common connection at all. With high power LEDs like this you should be using a constant current supply, resistors just do not cut it. Know these should have a current limiting resistor, I brought these led pcbs at Ebay, the seller doesn't really list any useful specifications, it says "Voltage 110-220V" which I find a little weird, but then again, I haven't even been able to calculate the resistor. I adjust my power supply to 15V, connect the load and it still says 15V. My power supply does output full voltage when the load is connected. But how do I calculate a resistor when all I really know about them is that they draw 75mA from my power supply when supplied with 15V? To be honest all I did was connecting these to my power supply, and slowly cranked up the voltage until I saw light, then one pcb seemed to run great at 15v. I know these should have a current limiting resistor, but I don't have any datasheet for the leds used on the pcb.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |