Custom Blinkin LED program (Pros Editor x64 C++)

After seeing the LED patterns on some of the robots at the last FRC competition, our team wanted to figure out how they managed to get the LEDS to react to their controls. Is there any documentation on how these programs are made? The specific editor we use is Pros Editor x64 C++. I have looked at the official users manual and it wasn’t very descriptive on how to program the LED strips.

Have you read the Blinkin user manual (PDF)? Section 3.1 shows you how it’s controlled (in essence, by reading the PWM output of a port on the roboRIO and reacting based on the value).

So if you want the robot to do something different based on a sensor reading, you’d just change the value of that PWM output once the roboRIO gets that sensor reading.

1 Like

FWIW, C++ code for dealing with Blinkin: https://github.com/Jagwires7443/Swerve/blob/master/src/main/cpp/subsystems/Infrastructure.cpp#L37.

We (3506) had someone that went all in on LEDs and developed a custom program to run them straight of the Rio with no other hardware. However, the power drawn by the LEDs can cause brownouts, so I recommend 12v LEDs and putting them into the PDH with only the signal wire going to the Rio.
You can look through our code here: https://github.com/Yeti-Robotics/aurora-java-2022
We are a java team so I do not know how helpful this is but good luck!

1 Like

We (6328) made use of LEDs this year both functionally (showing state to the drive team) and aesthetically (fun patterns, use at demos, etc.)

@Legojam05 it isn’t clear from your post if you already have LEDs mounted & wired; since you’re asking about the Blinkin I assume so. If it is working for you, great. The Blinkin didn’t work well for us; we experienced lockups that we were unable to resolve. Ultimately we mounted a cheap 5V regulator to power the LED strip as part of a “custom circuit”, and drove the data line from the Rio as @EHutson suggests. This was a surprisingly easy change and our programmers quickly took advantage of the greater degree of control to do some fancier things. Next time we do LEDs we will definitely go direct off the Rio from the beginning.

We’re also a Java team but our LED code may still be of interest. We have support for both Blinkin and Rio control due to the path we took; we use I/O abstraction layers as part of hardware interfacing, so there is an implementation for each kind of hardware.

Something to consider if your software is command based: while an obvious approach would seem to be to treat the LEDs as a “subsystem”, this doesn’t tend to work well in practice. Having commands “require” the LED subsystem (when many different commands may want to use them) invites conflicts and you do not want your use of LEDs to interfere with command operation! Far better to create the object that controls the LED in your RobotContainer and have a means for commands to simply call for a state change through an API. How best to provide access to the central LED object depends on your code structure. We keep a reference to it with some other widely accessible robot state information.

3 Likes

Thank you for the input! We do not have any LEDs mounted to our bot(s) as of right now. Ive heard that alot of teams are using Arduino’s to control their LED setups. I will have to look into the regulator.

One more sample point - 2022 codebase, which drove two small strips of LED’s off of an arduino. We used a PWM output from the RIO to communicate what pattern we wanted, and read that PWM at the arduino to choose how to set the colors and the patterns. We used the FASTLed library to control them.

I think this is what you’re referring to. Is this for a vex robot? If that’s the case you’ll likely find limited help here. If this is for a FIRST robot you’re probably using the wrong software.

2 Likes

You can certainly use an Arduino to drive the LEDs. But then if you want to control them from your robot program, you need a way to interface the Arduino to the Rio. (Again I’m assuming this is an FRC bot, if Vex then I’m not going to be able to help much.) You could interface the Rio to the Arduino in a number of ways, but this is going to be more complex than just using the Rio to control the LEDs directly.

This is the easy part. Amazon (and other sources) are awash in cheap 12-to-5V regulator modules that can do the job. A quick search turns up this this and this which are all 3A, enough for the typical short strips on a robot. If you’re running a LOT of LEDs you might want a 5A rated regulator, or even more. By spec, typical WS2812B RGB LEDs (what’s usually on the strips) can draw up to 50mA each. However, actual draw depends on color shown and brightness - full on white is the worst case, and if you’re doing typical color patterns the current will be much less on average.

If you have a custom circuit on the robot already, the regulator input can connect to that. If not, use a spare PDP or PDH circuit with either a 10A or 20A fuse.

To connect to the LED strip, you will either need to solder wires to the pads or use connectors like these. The connectors are much easier though still can be finicky; work carefully. Also, LED strips are directional - you MUST feed the control signal in the right end or it will not work.