# Programming Led Strips

I was wondering how to program led strips. I have the led soldered to a 3 pin wire that i plan on plugging into the digital port. I have looked into other threads that have been posted about this but none of the programs there worked for me. So i was wondering if anyone can help me with this.

I don’t have experience, but I’m going to guess that you just use a simple variable or something?

``````void turnOn
{
SensorValue[digital1] = 1
}
``````

As I said, I’m not experienced, but this is how I guess it would happen?

@Riley Thanks, but it did not work. I have LED’s

Try what @factorsofx said in this post:
https://vexforum.com/t/led-strip-lights/28893/1

https://vexforum.com/t/led-strip-lights/28893/1

If you go into the depths of the code in the link on the data sheet, you would see that Adafruit_NeoPixel.cpp sends RGB values and sometimes a white value. Not sure when they do that or why if it supposed to work with the same strip of lights.

This won’t work directly in robot C but am just showing you the setting of R G and B values per LED light. Sent the R and G and B values

``````// Set pixel color from separate R,G,B components:
uint16_t n, uint8_t r, uint8_t g, uint8_t b) {

if(n < numLEDs) {
if(brightness) { // See notes in setBrightness()
r = (r * brightness) >> 8;
g = (g * brightness) >> 8;
b = (b * brightness) >> 8;
}
uint8_t *p;
if(wOffset == rOffset) { // Is an RGB-type strip
p = &pixels[n * 3];    // 3 bytes per pixel
} else {                 // Is a WRGB-type strip
p = &pixels[n * 4];    // 4 bytes per pixel
p[wOffset] = 0;        // But only R,G,B passed -- set W to 0
}
p[rOffset] = r;          // R,G,B always stored
p[gOffset] = g;
p[bOffset] = b;
}
}

``````

You may want to check out Pololu’s page with similar lights. It has more useful details from the same lower level components.

^ Yea I was going to say that it’s practically impossible to program the different colors for those LEDs with ROBOTC… maybe just get one-color LEDS?

@Team80_Giraffes I tried that, but the problem is that, we are only using one digital port and i believe he is using 2 ports.

Not impossible.

The bigger issue is 60 LED’s @ maximum of 60mA per led. That’s way more current than is available on the digital port output power bus.

Wouldn’t the led strip work if it was 5v and not all 60 leds was used, what if only a few leds were used like 30 leds altogether.