Hello, I'm new to arduino and electronics in general. My question is if I could use this firmware for use with "leds LPD6803 pixel" (http://www.adafruit.com/datasheets/LPD6803.pdf) instead of WS2801 (as is implemented in the code).
//Arduino Mega Sketch to drive strands and matrices of WS2801 pixels with Glediator.
//(c)2012 by R. Heller
//wwww.solderlab.de
//Set Baudrate in Glediator to 1MBit !!!
//Change this to YOUR matrix size!!
#define Num_Pixels 16
//Serial Data Output (Arduino-Mega Pin 6)
#define SDO_Port PORTH
#define SDO_DDR DDRH
#define SDO_Pin 3
//Serial Data Clock (Arduino-Mega Pin 7)
#define CLK_Port PORTH
#define CLK_DDR DDRH
#define CLK_Pin 4
// Don't change anything upon here! #
#define Set_CLK_Low CLK_Port &= ~(1 << CLK_Pin)
#define Set_CLK_High CLK_Port |= (1 << CLK_Pin)
#define Set_CLK_Output CLK_DDR |= (1 << CLK_Pin)
#define Set_SDO_Low SDO_Port &= ~(1 << SDO_Pin)
#define Set_SDO_High SDO_Port |= (1 << SDO_Pin)
#define Set_SDO_Output SDO_DDR |= (1 << SDO_Pin)
#define CMD_NEW_DATA 1
unsigned char display_buffer[Num_Pixels * 3];
static unsigned char *ptr;
static unsigned int pos = 0;
volatile unsigned char go = 0;
void setup()
{
Set_SDO_Output;
Set_CLK_Output;
//Disable global interrupts
cli();
//UART Initialisation
UCSR0A |= (1<<U2X0);
UCSR0B |= (1<<RXEN0) | (1<<TXEN0) | (1<<RXCIE0);
UCSR0C |= (1<<UCSZ01) | (1<<UCSZ00) ;
UBRR0H = 0;
UBRR0L = 1; //Baud Rate 1 MBit
ptr=display_buffer;
//Enable global interrupts
sei();
}
void loop()
{
if (go==1) {shift_out_data(); go=0;}
}
//############################################################################################################################################################
// USART-Interrupt-Prozedur (called every time one byte is compeltely received) #
//############################################################################################################################################################
ISR(USART0_RX_vect)
{
unsigned char b;
b=UDR0;
if (b == CMD_NEW_DATA) {pos=0; ptr=display_buffer; return;}
if (pos == (Num_Pixels*3)) {} else {ptr=b; ptr++; pos++;}
if (pos == ((Num_Pixels3)-1)) {go=1;}
}
// Shift out Data #
void shift_out_data()
{
for (int i=0; i<Num_Pixels; i++)
{
byte r = display_buffer[i*3+0];
byte g = display_buffer[i*3+1];
byte b = display_buffer[i*3+2];
for (byte j=0; j<8; j++)
{
Set_CLK_Low;
if (r & (1<<(7-j))) {Set_SDO_High;} else {Set_SDO_Low;}
Set_CLK_High;
}
for (byte j=0; j<8; j++)
{
Set_CLK_Low;
if (g & (1<<(7-j))) {Set_SDO_High;} else {Set_SDO_Low;}
Set_CLK_High;
}
for (byte j=0; j<8; j++)
{
Set_CLK_Low;
if (b & (byte)(1<<(7-j))) {Set_SDO_High;} else {Set_SDO_Low;}
Set_CLK_High;
}
}
Set_CLK_Low;
delayMicroseconds(800); //Latch Data
}