IceMetal
Joined: 20 Nov 2008 Posts: 79 Location: white Plains, NY
|
RGB LED DRIVER |
Posted: Fri Jul 10, 2009 1:54 pm |
|
|
Hi guys I'm trying control an RGB led driver, the led driver has 2 inputs that I'm using, the clock the for every pulse selects the led and the SDI that everytime is high will light up the LED
The driver can control 8 RGB leds( 24 LEDS) so after 24 clock pulses it goes back to the begining of the led.
in between thouse pulses I have to set the SDI high to light up the LEDs I want, so I was thinking to send a command like R00011000 to lit up the 2 middle red LEDs, or B00011000 to lit up the 2 middle blue leds, how can I send 2 package of data like to select the color and the location of the LED.
Thank you guys.
Code: | #include <16F887.h>
#FUSES NOWDT
#FUSES NOMCLR
#FUSES NOCPD
#FUSES NOBROWNOUT
#FUSES XT
#use delay(clock=4000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
/////////////////////////////////////////////////////////////////////////////////
#define SDI PIN_D0
#define CLK PIN_D1
int i, data;
counting()
{
output_low(SDI);
for (i=0; i<data; ++i){
output_low(CLK);
delay_ms(100);
output_high(CLK);
delay_ms(100);
}
printf("%2x", data);
}
Main() {
output_high(SDI);
delay_ms(100);
output_high(CLK);
delay_ms(100);
output_low(CLK);
while(1){
if(kbhit())
{
data=getc();
counting();
}
}
} |
|
|