Practical LED Lighting

I’ve been working on setting up an Arduino with LEDs to put on the robot next year and I’ve been struggling to find resources on this but how to I connect the Arduino to the roborio via code so that the LEDs can update during the match based on info from sensors on the robot? Additionally how to I wire the Arduino effectively so that it is practical for a robot while being legal? This is what my wiring looks like right now.

1 Like

Are these WS2812-based? If so, I would skip the Arduino and control them directly from the roboRIO:

3 Likes

For the Rio - You can wire the signal output of any 3 wire individually addressable LEDS (such as this) and wire your power and ground to however you are powering it, either the VRM or a seperate 5V 10A converter that is powered off the rio for larger LED runs. You then wire the signal wire to the rio to one of the PWM ports. I believe WPILib has a library for this, or there is a library somewhere in VS Code, where you can set the PWM id of your leds. From there you can control it with RGB values in code. Someone better at code can chime in on that (@veg ?)

If you have some money available, the CTRE CANdle will probably solve what you’re looking for. Compatible with the LEDs you have from what I can tell, clean user-facing API, and controlled over CAN.

On the Arduino side, your best bet is probably connecting to the robot via Ethernet and receiving NetworkTables data indicating the state the robot’s in. This will require work on the Arduino code side to set up NT and change the LEDs according to what sensor readings you get.

There have been quite a few threads about putting LEDs on robots - here is a recent one with a bunch of good information.

I am a strong proponent of driving LEDs directly from the Rio using the Addressable LEDs support already linked above. 6328 has used this for the last couple of years and found it easy to use and flexible. The load on the Rio is negligible, and having full software control enabled us to make much better use of the LEDs. (Check out the “Pretty Lights” section of this kitchen sink update post in our build thread; we made heavy use of LED signaling this year.) Just know that you can only drive ONE strip with AddressableLEDs, although you can drive multiple strips with the same PWM signal output as long as you are OK with them each having the same pattern.

Our 2023 LED subsystem code is here. Some of it is probably more than you’re looking for but there is a lot of basics you could borrow. Many other teams had LED code you can peruse, as well.

For powering your strip, you may find this post on voltage regulators useful.

We tried a Blinkin in 2022, but switched to the direct Rio approach and never looked back. The CANdle will also work but is an even more expensive solution that’s still much more limited than AddressableLEDs.

I don’t think NetworkTables on an Arduino is a viable path (see this thread). If you’re really insistent on using the Arduino you could wire up some form of serial (I2C or serial port) connection and invent a simple protocol; or for selecting among a few patterns you could wire a few Rio DIO’s (driven from robot code) to Arduino digital inputs and read the binary pattern (e.g. 1 DIO lets you select between 2 patterns, 2 DIOs lets you select among 4 patterns, etc.). I think you’ll find that all of this is going to be way harder than just using the provided Rio support, though!

6 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.