How do I program one Led to turn off and off?

I am trying to get one led to turn on and off. So I have A led strip that has 32 leds. I am trying to make led 5 to turn off and on, and the color of red. The code is below.

I am miss something in my program. If you can help me out that would be great…

// * L2ggrrbb
// * 00 - LED off
// * 01 - LED on (max bright)
// * 10 - LED fade up (start at min bright)
// * 11 - LED fade down (start at max bright)

// Set which pins you will use to connect to the LED strip, you need 4 digital pins.
#define SIPIN 2
#define DIPIN 3
#define CLKPIN 4
#define LATCHPIN 5

#define LEDS 32 //Set this to the number of LEDs in your strip
#define CLOCK_DELAY (LEDS * 250)/1000 //This is the required delay between sending a bit and the clock line being fired.
//You can tweak this value lower until you find LEDs on the end of your chain misbehaving
//In fact, if you are running less than a few hundred LEDs you can get away with zero here.
//250nSec per LED is the specified value for the chip.

// These are the instructions that can be loaded for each LED in the strip.
// You must OR a Command or Commandx2 with any combination of the color operations.
// eg Command | BlueOn | RedDown will make an LED fad from Purpple to Blue.
// eg Commandx2 | GreenUp will make an LED fad UP to Green at double speed.
#define Command B10000000
#define Commandx2 B11000000 //Use this one to make dimming twice as fast.
#define BlueOff B00000000
#define BlueOn B00010000
#define BlueUp B00100000
#define BlueDown B00110000
#define RedOff B00000000
#define RedOn B00000100
#define RedUp B00001000
#define RedDown B00001100
#define GreenOff B00000000
#define GreenOn B00000001
#define GreenUp B00000010
#define GreenDown B00000011
#define White B00010101

unsigned char Lights[LEDS];

void setup()
{

//Set up our pins to connect to the LED strip.
pinMode(SIPIN, OUTPUT);
pinMode(DIPIN, OUTPUT);
pinMode(CLKPIN, OUTPUT);
pinMode(LATCHPIN, OUTPUT);
digitalWrite(SIPIN, LOW);
digitalWrite(DIPIN, LOW);
digitalWrite(CLKPIN, LOW);
digitalWrite(LATCHPIN, LOW);
int looper;
for ( looper = 0; looper < LEDS; ++looper ) {
Lights[looper] = BlueOff | RedOff | GreenOff;
}

}

void loop()
{
int looper;
for ( looper = 0; looper < LEDS; ++looper ) {
SendByte( Lights[looper] );
latch();
}
delay(50);

Lights[5] = RedOn;
for ( looper = 0; looper < LEDS; ++looper ) {
SendByte( Lights[looper] );
latch();
}
delay(50);

Lights[5] = RedOff | BlueOff | GreenOff;

}

void sPulse()
{
//Pulse the S line on the LEDs. This will make any LEDs that are fading do their thing.
//If the double speed bit IS set then two fades will occur. Once each time the pin is inverted.

digitalWrite(SIPIN, !digitalRead(SIPIN));
delayMicroseconds(100);
digitalWrite(SIPIN, !digitalRead(SIPIN));
delayMicroseconds(100);
}

void SendByte(unsigned char it)
{
//Send out one byte, don’t forget to LATCH it by calling latch()
//Note that for LARGE number of LEDs you may need to slow things down a little here.
digitalWrite(CLKPIN, LOW);

char x;
for(x=0;x < 8; x++)
{
if(B10000000 & it)
digitalWrite(DIPIN, HIGH);
else
digitalWrite(DIPIN, LOW);
it = it<<1;
// Wait here needs to be 250 x Number of LEDs nano seconds to allow data to propagate before being clocked in
delayMicroseconds(CLOCK_DELAY);
digitalWrite(CLKPIN, HIGH);
digitalWrite(CLKPIN, LOW);

}
}

void latch()
{
digitalWrite(LATCHPIN, HIGH);
delayMicroseconds(1); // spec sheet specifies minimum latch pulse of 1us
digitalWrite(LATCHPIN, LOW);
}

void runfader(int y, int d)
{
//Pulse the fader y times with delay d between each pulse
int x;
for(x=0;x<y;x++)
{
digitalWrite(SIPIN, LOW);
delay(d);
digitalWrite(SIPIN, HIGH);
delay(d);
}
}

please have alook at the shiftout command as it does what you are doing - http://arduino.cc/en/Tutorial/ShiftOut -

And please modify your post and use [ code] tags - use the # button just above the smileys - code looks better then

tip

normally the loopindex is defined in the for. This has to do with scope and non initialized variables. not wrong perse but it can cause hard to find bugs.

  for (int looper = 0; looper < LEDS; ++looper ) {
    Lights[looper] = BlueOff | RedOff | GreenOff;
  }

Can you explain what the problem is:

  • what do you expect
  • what do you get
  • what have you tried sofar

I am using the (RGB LED Strip - 32 LED/m Addressable - 1m). The code will go into the Arduino, but the led strip, not one leds is lighting up. All I am looking to do is to turn on #5 for some time and turn if off. Other programs work good, here are some of them.

// Example code to use with LED strip with 1606 controller chip


// *       L2ggrrbb
// *       00 - LED off
// *       01 - LED on (max bright)
// *       10 - LED fade up   (start at min bright)
// *       11 - LED fade down (start at max bright)

// Set which pins you will use to connect to the LED strip, you need 4 digital pins.
#define SIPIN 2
#define DIPIN 3
#define CLKPIN 4
#define LATCHPIN 5

#define LEDS 32    //Set this to the number of LEDs in your strip
#define CLOCK_DELAY (LEDS * 250)/1000  //This is the required delay between sending a bit and the clock line being fired.
                                        //You can tweak this value lower until you find LEDs on the end of your chain misbehaving
                                        //In fact, if you are running less than a few hundred LEDs you can get away with zero here.
                                        //250nSec per LED is the specified value for the chip.


// These are the instructions that can be loaded for each LED in the strip.
// You must OR a Command or Commandx2 with any combination of the color operations.
// eg Command | BlueOn | RedDown will make an LED fad from Purpple to Blue.
// eg Commandx2 | GreenUp will make an LED fad UP to Green at double speed.
#define Command B10000000 
#define Commandx2 B11000000 //Use this one to make dimming twice as fast. 
#define BlueOff B00000000 
#define BlueOn B00010000 
#define BlueUp B00100000 
#define BlueDown B00110000 
#define RedOff B00000000 
#define RedOn B00000100 
#define RedUp B00001000 
#define RedDown B00001100 
#define GreenOff B00000000 
#define GreenOn B00000001 
#define GreenUp B00000010 
#define GreenDown B00000011 
#define White B00010101 

void setup()
{
 
  //Set up our pins to connect to the LED strip.
  pinMode(SIPIN, OUTPUT);
  pinMode(DIPIN, OUTPUT);
  pinMode(CLKPIN, OUTPUT);
  pinMode(LATCHPIN, OUTPUT);
  digitalWrite(SIPIN, LOW);
  digitalWrite(DIPIN, LOW);
  digitalWrite(CLKPIN, LOW);
  digitalWrite(LATCHPIN, LOW);
 
}  

void loop()
{
  int looper;
  for ( looper = 0; looper < LEDS; ++looper ) {
    SendByte(BlueOff | RedOff | GreenOff );
    latch();
  }
  
  delay(50);
  
  for ( looper = 0; looper < LEDS; ++looper ) {
    if ( looper == 1 ) {
      SendByte ( RedOn );
    } else {
      SendByte ( BlueOff | RedOff | GreenOff );
    }
    latch();
  }
  
  delay(50);
}


void sPulse()
{
  //Pulse the S line on the LEDs. This will make any LEDs that are fading do their thing.
  //If the double speed bit IS set then two fades will occur. Once each time the pin is inverted.
  
  digitalWrite(SIPIN, !digitalRead(SIPIN));
  delayMicroseconds(100);
  digitalWrite(SIPIN, !digitalRead(SIPIN));
  delayMicroseconds(100);
}

void SendByte(unsigned char it)
{
  //Send out one byte, don't forget to LATCH it by calling latch()
  //Note that for LARGE number of LEDs you may need to slow things down a little here.  
  digitalWrite(CLKPIN, LOW);

  char x;
     for(x=0;x < 8; x++)
    { 
    if(B10000000 & it)
      digitalWrite(DIPIN, HIGH); 
    else
      digitalWrite(DIPIN, LOW); 
    it = it<<1;
    // Wait here needs to be 250 x Number of LEDs nano seconds to allow data to propagate before being clocked in
    delayMicroseconds(CLOCK_DELAY);
    digitalWrite(CLKPIN, HIGH);
    digitalWrite(CLKPIN, LOW);

    }
}

void latch()
{
  digitalWrite(LATCHPIN, HIGH);
  delayMicroseconds(1);  // spec sheet specifies minimum latch pulse of 1us
  digitalWrite(LATCHPIN, LOW);
}

void runfader(int y, int d)
{
  //Pulse the fader y times with delay d between each pulse
  int x;
  for(x=0;x<y;x++)
  {
    digitalWrite(SIPIN, LOW);
    delay(d);
    digitalWrite(SIPIN, HIGH);
    delay(d);
  }
}