EDIT: Here is the strip that I own: RadioShack.com Official Site - America's Technology Store Hope that helps.
Hello everyone, new to the forums, new to the Arduino, new to this nightmare of an LED strip. I already know I made a mistake by purchasing the Radio Shack strip, and I should have purchased one off adafruit.com; however, I'm getting close I feel to figuring this thing out... I just need a little help in the right direction.
After extensively searching Google/YouTube, it seems just about nobody has any useful example code on this strip. The documentation Radio Shack gives you (As a 'Level 1 Beginner') is more useful as toilet paper than it is a tutorial on how to use the strip. I would give the code, but it's way too long.
After looking through it and getting rid of all the garbage they supply, I was able to shrink it down to this... and I was able to grasp a little understanding of how their code works. What I can't understand is that send_strip function or why the data is stored in the flash memory rather than just sent straight out... anyway... here is the code that I have it down to:
#include <avr/pgmspace.h>
// ******** DEBUG ==== should auto config to adapt different mother board *********
#define DATA_1 (PORTC |= 0X01) // DATA 1 // for UNO
#define DATA_0 (PORTC &= 0XFE) // DATA 0 // for UNO
#define STRIP_PINOUT (DDRC=0xFF) // for UNO
//Actually is GBR not RGB format
PROGMEM unsigned long outputvalue[][10]={
{0X009900, 0X0089AA, 0X007700, 0XFF6600, 0X005500, 0XDD4400, 0X003300, 0X002200, 0X001100, 0X000000},
};
void setup()
{
STRIP_PINOUT; // set output pin - DEBUG: should auto detect which mother board for use
reset_strip();
//noInterrupts();
}
void loop()
{
send_1M_pattern(outputvalue);
delay(50);
}
void send_1M_pattern(unsigned long data[][10])
{
int i=0;
int j=0;
int frame_rate = 10;
uint32_t temp_data;
noInterrupts();
for (j=0;j<10;j++)
{
temp_data=pgm_read_dword_near(&data[i][j]);
send_strip(temp_data);
}
interrupts();
delay(frame_rate);
}
void send_strip(uint32_t data)
{
int i;
unsigned long j=0x800000;
for (i=0;i<24;i++)
{
if (data & j)
{
DATA_1;
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
DATA_0;
}
else
{
DATA_1;
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
DATA_0;
}
j>>=1;
}
}
void reset_strip()
{
DATA_0;
delayMicroseconds(20);
}
Much cleaner. Here's the problem. How can I change the output color on the fly? Since the data is stored in the flash memory before the program even starts, I am unsure how to change it. I would rather eliminate the memory aspect of the code all together and just have it pass an array if that would work. I don't understand the defines up top, I don't understand why it has to be stored (or how to change it), and I don't understand that send_strip function at all.
Can somebody PLEASE save me (and I'm sure MANY others) from bashing my head against a wall.