Need to drive 4 rgb leds, but have only 1 pin available...
Hello.
The situation is as follows:
PIC16F877A, running @ 8mhz intosc.
Have 1 free pin available (can alocate any, including one with PWM output).
Need to drive 4 rgb leds. All 4 should change colors together, so it can be considered as a single led. There is no animation, color effects or whatever - this is backlight and it will be tuned to specific value once configured and that's all.
I'd like to do it with as few extra components as possible, due to lack of available space.
I have the following ideas:
1. Add another MCU in 8 pin case, say, 12F683, connect it to main chip via serial and use it to drive leds via bitbam or whatever.
2. Use WS2812 LEDs, and to solve timing issues, wire them in parallels, instead of serial?
3. As a last resort - use only two colors of leds, say red and blue, and use inverted HPWM to drive them.
Of course, I'd like to do #2 - requires less extra hardware than others, but is this doable on 16F887?
Re: Need to drive 4 rgb leds, but have only 1 pin available...
PIC16F877A has internal osc?
On 20MHz, with WS2812 LED try this: http://www.picbasic.co.uk/forum/showthread.php?t=23399
Should be work.
Re: Need to drive 4 rgb leds, but have only 1 pin available...
Sorry I should write 887A.
Yes I have read that, but I don't have 20Mhz capability, so this is why I'm asking.
Re: Need to drive 4 rgb leds, but have only 1 pin available...
OK, I try to decreasing the clock frequency, and the minimum clock is 16MHz and the WS2812 works fine.
In my case at 8MHz the WS2812 not work.
Pulse generator code for 16MHz looks like this:
Code:
;------------ Pulse generator ---------------
NeoBit:
IF DataBit = 1 THEN
;generate 800ns pulse
NeoPin = 1
ASM
nop
ENDASM
NeoPin = 0
ELSE
;generate 400ns pulse
NeoPin = 1
ASM
ENDASM
NeoPin = 0
ENDIF
RETURN
Re: Need to drive 4 rgb leds, but have only 1 pin available...
With the APA101 clock frequency is not an issue. We did some experiments in this thread:
http://www.picbasic.co.uk/forum/show...ghlight=apa101
Ioannis
Re: Need to drive 4 rgb leds, but have only 1 pin available...
Yes, but APA needs two legs. Data and clock,. Or I'm wrong?
Re: Need to drive 4 rgb leds, but have only 1 pin available...
Yes, you are right. Forgot that, sorry!
Ioannis
Re: Need to drive 4 rgb leds, but have only 1 pin available...
If you are trying to get a specific color from your RGB, and you aren't needing to change that color, use different value resistors from VREF to your individual LED legs and use the PIC to provide ground. For brightness control, you could use that one PWM pin on your PIC and vary duty cycle. You wouldn't be able to change the colors, due to the fixed resistors.
Re: Need to drive 4 rgb leds, but have only 1 pin available...
Quote:
Originally Posted by
louislouis
Yes, but APA needs two legs. Data and clock,. Or I'm wrong?
Not necessary, you can create clock and data using only one pin.
eg
https://www.romanblack.com/shift1.htm
Re: Need to drive 4 rgb leds, but have only 1 pin available...
This is customizable backlight, so user will be setting the color. Idea with shift register is nice, but if I have to add an extra IC, I can add say 12F683 and use it directly to drive RGB leds. Footprint will be much smaller :)
Re: Need to drive 4 rgb leds, but have only 1 pin available...
You missed the point...
Use same RC circuit to drive APA LED. Apa have Data and Clock pin and you have one pin free.
Re: Need to drive 4 rgb leds, but have only 1 pin available...
Out of the box. A small PIC device running the 4 LEDs and reading a 2 bit serial pattern with a longish pause to sync.