LED strip lights

I’m sure others have asked this in the past. We would like to plug in an LED strip light to the cortex. It has to be 5V or under as that is what the digital ports can supply. Is there a good source for these lights somebody can direct me to?

Our team has been using LED under glow all season, this is the set of lights that we are using, but in a different color.

I just ran some rgb light strips on my robot at state. They might have been 12v strips but they worked on the 5v power source and the light can be changed. You can find them all over the place online.

Did you all have to put your own connector ends on for them to plug into the cortex? Or did you find strips that already had appropriate connectors?

The lights I used I had to sodder the wires to and then splice into a 3-wire to plug it into the cortex.

I personally don’t care that you did that, but I don’t think that is legal. I believe Karthik said that if LED’s were used they had to be purchases “as is”. I hope I’m wrong, because I think we should be able to solder all we want for something that is only a decoration anyways.

Edit: This was the best Q&A I could find regarding it.

https://vexforum.com/t/answered-led-lights-for-decoration/27853/1&highlight=light

It only says you must “power them legally”. I’m not sure what to think when it comes to modifying wires. It’s essentially illegal to modify wires for reasons other than repair…correct? I sure hope we can solder connectors onto LED strips. This would allow a much wider array of LED’s to be used. There are very few options that exist with the right voltage and connector to work with the cortex.

We had our regional director at our tournament and he actually asked how I was powering them and I explained it and he was good with it. Since it’s a decoration, I figured as long as it’s powered by the cortex its legal. If not, feel free to correct me.

Edit: To make the answer official, I asked about it in the Official Q&A.
https://vexforum.com/t/answered-legal-led-powering/28898/1

dart48, I’m surprised how your LED strips that are rated on 12V can run on 5V. You can run them at 5V but it’ll surprising if you can keep running them at the same voltage for a long time. Since running LED stripes at a lower voltage suggests that you’ll be requiring more current to power them up, overheating due to this excessive current will eventually cause your LEDs to blow out.

I don’t think they are powered by the 5v output of the cortex but instead a motor port which is full battery voltage. This gets you up to 7-8 volts, which is a bit more reasonable to run certain 12v LED’s with.

if you need DC5V ,you can use digital led strip 5V , such as ws2812b led , sk6812 led strip .

I used the 5v APA102C strips from pololu, they’re really easy to control straight from the cortex if you solder some 3-wire plugs on.

@factorsofx Do you control them with PWM or???

To control the ones I linked, you need to have two digital output ports hooked up to the clock and data lines. Then you use the protocol described in the datasheet to send data to the lights. It’s a bit complicated but once you have a function in place to do it it’s really easy. If you want I can write a demo program to show you.

Clock and data? Wouldn’t you have to manually pull the pins high and low timed perfectly? I think to write a function that does that would take a painstakingly long time. But yes please if you could send me a demo program that would be awesome. Clearly you know of a simpler way.

We just ordered some lights from Pololu so sample code would help us a ton too!

Alright my original code was for the arduino and I lost it, so working from memory and the datasheet, I wrote this. Note that it hasn’t been tested, but it should work. If there are issues that you can’t figure out, please tell me and I’ll try to fix them.

This is not a full program, just some functions to help work with the lights. Hook up clock to a digital out named clock, and data the same way. Sorry if the code is unreadable or written poorly, I tried to comment.

void startTransmission() //Send Start Frame
{
	for(int i = 0; i < 4; i++)
	{
		sendByte(0);
	}
}

void endTransmission() //Send End Frame
{
	for(int i = 0; i < 4; i++)
	{
		sendByte(255);
	}
}

void sendByte(int byte) //Send 8 bits, most significant to least significant.
{
	for(int i = 128; i >= 1; i = i / 2)
	{
		SensorValue[data] = byte & i;
		SensorValue[clock] = 1;
		//This is where you may want to add a delay if it is being unreliable
		SensorValue[clock] = 0;
	}
}

//Send a single LED frame, these get pushed down the strip as more and more are added
//Brightness: From 0 to 31, an LED-wide modifier to the brightness
//R,G,B: The RGB color value of the LED
void sendLEDFrame(int brightness, int r, int g, int b)
{
	sendByte(224 | brightness); //The brightness byte is 111xxxxx, there are only 5 bits that you can use
	sendByte(b);
	sendByte(g);
	sendByte(r);
}

//Sets the whole strip's color and brightness
//Length: How many LEDs are in the strip
//Brightness, R,G,B: Same as above
void setStripColor(int length, int brightness, int r, int g, int b) //Set the whole strip to a uniform color.
{
	startTransmission();
	for(int i = 0; i < length; i++)
	{
		sendLEDFrame(brightness, r, g, b);
	}
	endTransmission();
}

@factorsofx wait so does this compile with robotc? Or do we need an arduino?

This Should work on the cortex, again it’s not a full file, just functions, and I haven’t tested it. Also you’ll need to solder the wires from the strips onto 3-wire plugs to the cortex.

@factorsofx This is very clever stuff. Definitely going to use it. Do you know if it would be possible to control individually addressable LEDs? Particularly this one?

Oh wait that code is for addressable leds. Derp. Just one last thing, I promise: What would you exactly write if you wanted to update the color of say, led 7 of 40. Then, you want to update led 8. Finally, you want to update led 7 again. I just cant wrap my head around how send LED frame works.