I would like to send a RGB LED strip with four potentiometers:
3 potentiometers for the colors red, green, blue. With the fourth potentiometer I want to adjust the brightness. Now, most microcontrollers have 4 A/D inputs, but I would also have 3 ports with a PWM output for the colors. Can anyone give me some advice which microcontroller (type) I can use? Where can I find some examples like this? I don't want to buy a driver but maked it by myself
Pretty much any microcontroller could be programmed to do this task - the solution would be to do the PWM in software, rather than using the on-chip PWM hardware (which, as you noticed, may not exist).
The easiest way I find to do this is by running the PWM in the main loop. The frequency may vary somewhat as other events happen, but on average this will provide adequately fast PWM for visible LED color applications. As an example:
/* Physical outputs to LEDs (syntax is processor/compiler dependent) */ sbit RedLed P1^1; sbit GrnLed P1^2; sbit BluLed P1^3;
while(TRUE) { /* Do something to acquire values for Red, Grn, and Blu (0..255) */ Red = GetPotentiometer(1); Grn = GetPotentiometer(2); Blu = GetPotentiometer(3);
Note that this method can have a problem. If something happens in the main loop (such as processing a received command) that takes significant processor time (even a few milliseconds), there will be a noticeable perturbation in the brightness of the LEDs. The most reliable way around this is to place the PWM logic in a timer service routine, rather than in the main loop.
The downside of using the timer method is that the timer must trigger fairly rapidly in order to keep the PWM frequency high enough to prevent visible strobing of the LEDs (10 kHz or so), and the additional overhead required by the interrupt service may use up too many processor cycles. This can be mitigated by decreasing the resolution of the PWM from 1/256 to, perhaps,
1/16 (0..0x0F). This reduces the number of distinct colors available, but in many cases (most, in my experience) still provides adequate color rendition.
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.