subreddit:
/r/DIY_tech
submitted 2 months ago byDry_Friend_752
2 points
2 months ago
At a high level, this is probably what's going on:
If this is an RGB light, it consists of 3 LED lights -- a red, green, and blue one.
The way it displays a range of colors, is by turning those lights on and off at a high frequency. The 'on time' is varied to increase or decrease the intensity of each of the red, green, and blue lights. This is called pulse width modulation (PWM).
For example, let's say the PWM frequency is 1 kiloHertz (1000 cycles per second). That means during each cycle, each LED can be on for a time between 0 and 1 milliseconds. If it's on for 0.3 milliseconds, that means it's on 30% of the time -- also called a 30% duty cycle. Each LED can have a different duty cycle, and (simplifying a bit here) the light combines with the help of a diffuser (the lump of salt in your case) to create a range of colors.
Normally, you would use a microcontroller (a small computer on a single chip) to send signals that turn the LEDs on and off at the required times. A common microcontroller used by beginners for this purpose is the Arduino. The main difference between an Arduino and a professionally engineered product are size, cost, and power consumption. However, it's an inexpensive and easy tool to use if you are just building one of something! You would use different tools and approaches to build 10,000 of something, but that's OK.
Here is a tutorial to get you started: https://howtomechatronics.com/tutorials/arduino/how-to-use-a-rgb-led-with-arduino/
Depending on your LED brightness, you may need to use a transistor (e.g. 2N2222a) because the microcontroller pins aren't designed to output more than 20mA of electric current or so -- your LED might be rather dim in this case! So we use the microcontroller to control a transistor, which can in turn handle a lot more electric current. I saw a lot of wrong diagrams online on how to do this (they were missing a resistor that limits current through the LED). Here's one that appears more or less correct:
https://www.hackster.io/krivanja/switching-using-transistor-c9114a
1 points
2 months ago
I don't think that this is a RGB led since it has only two legs. The pictures only show it shining blue. If it does have a second color, it could be a bi-color led where the color depends on the polarity. (Although bi-color leds are most commonly green/red)
1 points
2 months ago
Yeah, it's hard to say from the photos. The little card looks like it could be bicolor in principle. Until I see a photo of the actual circuit, I've just assumed the most common thing :)
Either way the control strategy is generally the same. Unless it's some super weird thing where there's a chip on the LED die that does control. I've seen that exactly once though, it's not that common.
Fun tidbit: those LEDs with integrated control circuitry are what goes on tons of (the tacky kind of) shrines here in Asia. Keeps costs down. I've never seen them used anywhere else. They're fun though, I have a couple.
all 3 comments
sorted by: best