Skip to content

Tutorial: Your First Canandcolor

This tutorial covers the complete setup of a Redux Canandcolor. By the end of this lesson, you will have a wired, configured, and programmed sensor reading color and proximity.

  • A Redux Canandcolor
  • A RoboRIO with a configured CAN bus
  • A laptop with WPILib VSCode installed
  • A basic FRC robot project
  1. Basic Wiring
    Connect the Canandcolor to your robot’s CAN bus.

    • CAN High: Yellow wire to the yellow wire.
    • CAN Low: Green wire to the green wire.
    • Power (12V): Red wire to a 12V source.
    • Ground: Black wire to the corresponding ground port.
  2. Install ReduxLib
    Open your FRC project in VSCode.

    • Press Ctrl+Shift+P.
    • Select WPILib: Manage Vendor Libraries.
    • Choose Install new libraries (online).
    • Paste the ReduxLib URL: https://frcsdk.reduxrobotics.com/ReduxLib_2026.json
  3. Configure the CAN ID
    All Redux devices ship with CAN ID 0. We need to give it a unique ID using the Alchemist or the web dashboard.

    • Deploy a basic robot project that includes CanandEventLoop.getInstance(); in robotInit.
    • Open a web browser and navigate to http://roborio-XXXX-frc.local:7244 (replacing XXXX with your team number).
    • Find the device with ID 0, type 1 into the CAN device ID box, and click Change ID.
  4. Write your first code
    In your Robot.java file, let’s read the proximity and color from the sensor.

    import com.reduxrobotics.sensors.canandcolor.Canandcolor;
    public class Robot extends TimedRobot {
    // Create the sensor object with ID 1
    private final Canandcolor m_colorSensor = new Canandcolor(1);
    @Override
    public void teleopPeriodic() {
    // Read proximity [0..1]. Values DECREASE as objects get closer.
    double proximity = m_colorSensor.getProximity();
    // Read the Hue [0..1)
    double hue = m_colorSensor.getHSVHue();
    System.out.println("Proximity: " + proximity + " | Hue: " + hue);
    }
    }
  5. Verify on the Dashboard
    Deploy your code and open the RIOlog. Place an object in front of the sensor; you should see the proximity value decrease. Try different colored objects to see the Hue value change!

Now that you have the basics working, check out our FRC-specific tutorials:

Or explore the Programming Guide to learn about HSV tuning and digital output triggers.