Sparkfun RGB LED Strip — code issues

I don't seem to be able to make the strip work with my own code.

The example code works but everytime I try to modify it I can't seem to get it to work ok. I just get the first LED changing colour randomly.

The example code is at http://www.sparkfun.com/datasheets/Components/LED/LED_Strip_Example.pde

Any pointers would be most appreciated!

Here's some code that I've written.

/*
  Blue = 5V
  Red = SDI
  Green = CKI
  Black = GND
*/

int SDI = 2; //Red wire (not the red 5V wire!)
int CKI = 3; //Green wire
int ledPin = 13; //On board LED

long p[4096];

void setup() {
  pinMode(SDI, OUTPUT);
  pinMode(CKI, OUTPUT);
  pinMode(ledPin, OUTPUT);
  
  
  //clear data in the RGB strip
  for (int x = 0; x < 32; x++) {
    pushRGB(0x000000);
  }
  digitalWrite(CKI, LOW);
  delayMicroseconds(500);
  
  loaddata();
}

void loop() {
  for (int x = 0; x < 32; x++) {
    pushRGB(p[x]);
  }
  digitalWrite(CKI, LOW);
  delayMicroseconds(500);
}

void pushRGB (long colour) {
      for(byte color_bit = 23 ; color_bit != 255 ; color_bit--) {
      //Feed color bit 23 first (red data MSB)
      
      digitalWrite(CKI, LOW); //Only change data when clock is low
      
      long mask = 1L << color_bit;
      //The 1'L' forces the 1 to start as a 32 bit number, otherwise it defaults to 16-bit.
      
      if(colour & mask) 
        digitalWrite(SDI, HIGH);
      else
        digitalWrite(SDI, LOW);
  
      digitalWrite(CKI, HIGH); //Data is latched when clock goes high
    }   
}

void loaddata() {

p[0] = 0xFF3B36;
p[1] = 0xFF1F18;
p[2] = 0xFF1408;
p[3] = 0xFF1703;
p[4] = 0xFF2602;
p[5] = 0xFF3D03;
p[6] = 0xFF5F05;
p[7] = 0xFE8B0A;
p[8] = 0xFEB90D;
p[9] = 0xFEDE0E;
p[10] = 0xFEF40B;
p[11] = 0xFEFC07;
p[12] = 0xFDFE05;
p[13] = 0xF9FF07;
p[14] = 0xF2FF0E;
p[15] = 0xE4FF1E;
p[16] = 0xCBFF39;
p[17] = 0xA5FE60;
p[18] = 0x78FD8F;
p[19] = 0x52F9B9;
p[20] = 0x3DF2DA;
p[21] = 0x3EE6ED;
p[22] = 0x57D2F8;
p[23] = 0x83B6FD;
p[24] = 0xB493FE;
p[25] = 0xDB6BFF;
p[26] = 0xF144FF;
p[27] = 0xFB25FE;
p[28] = 0xFD10FE;
p[29] = 0xFD07FE;
p[30] = 0xFD08FD;
p[31] = 0xFC13FC;
p[32] = 0xFF3933;
p[33] = 0xFF2016;
p[34] = 0xFF1808;
p[35] = 0xFF1D02;
p[36] = 0xFF2E02;
p[37] = 0xFF4703;
p[38] = 0xFF6905;
p[39] = 0xFE9309;
p[40] = 0xFEBE0D;
p[41] = 0xFEE10D;
p[42] = 0xFEF50A;
p[43] = 0xFDFC07;
p[44] = 0xFBFE06;
p[45] = 0xF6FF0A;
p[46] = 0xEDFF14;
p[47] = 0xDDFF25;
p[48] = 0xC3FE41;
p[49] = 0x9EFD68;
p[50] = 0x74FB95;
p[51] = 0x52F7BE;
p[52] = 0x42EEDC;
p[53] = 0x47DFEF;
p[54] = 0x60CAF9;
p[55] = 0x8BADFD;
p[56] = 0xB98AFE;
p[57] = 0xDD64FF;
p[58] = 0xF240FE;
p[59] = 0xFB23FE;
p[60] = 0xFC11FD;
p[61] = 0xFC09FC;
p[62] = 0xFA0CFA;
p[63] = 0xF918F9;
p[64] = 0xFF372F;
p[65] = 0xFF2115;
p[66] = 0xFF1C07;
p[67] = 0xFF2502;
p[68] = 0xFF3802;
p[69] = 0xFF5203;
p[70] = 0xFE7305;
p[71] = 0xFE9B09;
p[72] = 0xFEC40C;
p[73] = 0xFEE40C;
p[74] = 0xFDF60A;
p[75] = 0xFCFD07;
p[76] = 0xF9FE08;
p[77] = 0xF2FF0E;
p[78] = 0xE6FF1A;
p[79] = 0xD4FF2D;
p[80] = 0xBAFE4A;
p[81] = 0x97FD71;
p[82] = 0x71F99B;
p[83] = 0x54F3C2;
}

Another go using the WS2801 library.

#include "WS2801.h"

/*
  Blue = 5V
 Red = SDI
 Green = CKI
 Black = GND
 */

int dataPin = 2; //Red wire (not the red 5V wire!)
int clockPin = 3; //Green wire

WS2801 strip = WS2801(32, dataPin, clockPin);

uint32_t p[4096];

void setup() {
  
  strip.begin();
  strip.show();

  //loaddata();
  
  p[0] = 0xFF3B36;
p[1] = 0xFF1F18;
p[2] = 0xFF1408;
p[3] = 0xFF1703;
p[4] = 0xFF2602;
p[5] = 0xFF3D03;
p[6] = 0xFF5F05;
p[7] = 0xFE8B0A;
p[8] = 0xFEB90D;
p[9] = 0xFEDE0E;
p[10] = 0xFEF40B;
p[11] = 0xFEFC07;
p[12] = 0xFDFE05;
p[13] = 0xF9FF07;
p[14] = 0xF2FF0E;
p[15] = 0xE4FF1E;
p[16] = 0xCBFF39;
p[17] = 0xA5FE60;
p[18] = 0x78FD8F;
p[19] = 0x52F9B9;
p[20] = 0x3DF2DA;
p[21] = 0x3EE6ED;
p[22] = 0x57D2F8;
p[23] = 0x83B6FD;
p[24] = 0xB493FE;
p[25] = 0xDB6BFF;
p[26] = 0xF144FF;
p[27] = 0xFB25FE;
p[28] = 0xFD10FE;
p[29] = 0xFD07FE;
p[30] = 0xFD08FD;
p[31] = 0xFC13FC;
p[32] = 0xFF3933;

}

void loop() {
  for (int x = 0; x < 32; x++) {
    strip.setPixelColor(x, p[x]);
  }
  strip.show();
  delay(100);
}

I am new to Arduino but not digital controls. I have been computer controlling my christmas lights for about 10 yrs. I purchased 2x100 strings of ws2801s to play around with.

Did you get your PC app to work to your satisfaction? Are there any commercial apps that can be used to make patterns?

There are DMX solutions that, with some minor code changes, can control a WS2801 strip, but you'll have to look on Google for those. You can of course write your own patterns and designs and do it all yourself.