RevBlinkin Programming LEDs FRC

Hello! I am currently starting work with the REVBlinkin. We have the LEDs hooked up to the 5V Port and plugged into PWM port 9 on the RoboRio. When we plug it in it turns on, but we are trying to program specific colors onto it. For example, the LEDs would activate when picking up an object. I have provided my current code. Could someone provide guidance as to how we should proceed for the commands?

package frc.robot.subsystems;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import edu.wpi.first.wpilibj.motorcontrol.Spark;


public class RevBlinkin extends SubsystemBase {
  private static Spark m_blinkin = null;
  public RevBlinkin() {
    m_blinkin = new Spark(9);
    solid_orange();
  }

  public void set(double val) {
    if ((val >= -1.0) && (val <= 1.0)) {
      m_blinkin.set(val);
    }
  }

  public void rainbow() {
    set(-0.99);
  }

  public void solid_orange() {
    set(0.65);
  }
}

You could make the class a singleton, and call the methods whenever else in your code you want to activate the LEDs

You don’t want to use the spark class but instead the PWM class. We used these last year and were never able to get it to work using the spark class as per the Rev documentation. We switched to using the PWM class after advice from 6328 and it worked right away.
Here is a link to the code we had last year.Skip-5.12/BlinkinLedDriver.java at master · WHS-FRC-3467/Skip-5.12 · GitHub

C++ code, but we used the Spark class and things worked great: Swerve/Infrastructure.cpp at master · Jagwires7443/Swerve · GitHub.

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