Every sensor on an FRC robot reports through one of a few electrical interfaces, and knowing them helps you wire and program correctly the first time.
Digital I/O (DIO)#
The roboRIO has 10 built-in DIO ports (0-9). On the roboRIO these ports operate at 5V logic: a 'high' signal is ~5V and 'low' is 0V (the input threshold reads high above ~2.0V and low below ~0.8V). DIO is used for:
- Switches (limit switches, beam breaks) that are simply open or closed.
- Quadrature encoders, which send two fast on/off pulse trains.
- Duty-cycle (PWM) absolute encoders, where the width of a repeating pulse encodes position.
Every DIO port has a built-in pull-up resistor between power and signal, so a normally-open switch wired between signal and ground reads true (high) when open and false (low) when pressed — a detail that trips up many rookies.
Analog Input#
The roboRIO has 4 built-in analog input channels (0-3) that read a continuous voltage from 0-5V with 12-bit resolution. Analog sensors output a voltage proportional to what they measure — for example, an analog potentiometer or an analog absolute encoder where 0V = 0 degrees and 5V = one full rotation.
CAN bus#
The CAN (Controller Area Network) bus is a single daisy-chained, terminated pair of wires that connects many smart devices: motor controllers (Talon FX, Spark MAX/Flex), the Power Distribution Hub/Panel, the Pigeon 2.0 IMU, the CTRE CANcoder, and CAN distance sensors. Each device has a unique ID. CAN is powerful because:
- A device can do its own processing and report rich data (position, velocity, temperature, current).
- You add devices without using up roboRIO ports.
- Modern CTRE devices support CAN FD for higher bandwidth.
The trade-off is bus utilization and latency: too many devices polled too fast can saturate the bus, so frame/update rates are configurable.
Choosing an interface#
Use DIO for switches and most encoders, analog for simple potentiometers, and CAN for anything that benefits from on-device smarts or that you want to read without wiring back to the roboRIO. As a rule of thumb, prefer the interface the manufacturer designed the sensor for, and always confirm a sensor's logic level is compatible before wiring it to a 5V DIO port.
the part worth keeping
Key takeaways
- The roboRIO offers 10 built-in DIO ports, 4 built-in analog inputs, and a CAN bus; pick the interface a sensor was built for.
- roboRIO DIO ports are 5V logic with built-in pull-ups, so an open normally-open switch reads true and a pressed switch reads false.
- CAN devices do their own processing and report rich data, but the bus has finite bandwidth you must budget.
Programming, Controls & SensorsSensing Fundamentals: Digital, Analog, and CAN Inputslesson 1 of 3
Keep going
Take the quiz+10 XP with an accountMore in Sensing Fundamentals: Digital, Analog, and CAN Inputs
where this came from
Sources and corrections
This lesson is AI-assisted: drafted from primary sources, then reviewed and edited by hand. Errors still get through. When one is reported we fix it and write down what changed, in public, in the corrections log.
sources and further reading
- docs.wpilib.orgWPILib: Digital Inputs (hardware)
- docs.wpilib.orgWPILib: Digital Inputs (software)
clipped to this lesson
Articles that go further on this
The lesson gets you through the topic. These go wider on it, and they read in one sitting.
answer sheet
Lesson quiz
All 3 right completes the lesson. Miss one and only that question comes back, anything you already answered correctly stays banked.
0 of 3 answered
01On the roboRIO, which type of port is best suited for a sensor that reports a continuously varying value as a proportional voltage, such as a potentiometer or an analog absolute encoder?
02How is the CAN bus physically wired on an FRC robot?
03A normally-open switch is wired between a roboRIO DIO signal pin and ground. What does the port read while the switch is open (not pressed)?
Answer every question to submit.
All 51 lessons in Programming, Controls & Sensorsopenclose
01 / prerequisites
02 / foundations-tools-and-first-program
03 / robot-program-and-command-based
04 / motors-and-control
05 / autonomous-trajectories-simulation
06 / sensing-fundamentals
07 / encoders
08 / gyros-imus-orientation
09 / closed-loop-control
10 / vision-pose-estimation
11 / worked-examples-mini-projects
- Not read yet:Mini-Project: A Closed-Loop Elevator with Motion Magic
- Not read yet:Mini-Project: A Velocity-Controlled Shooter on REVLib
- Not read yet:Mini-Project: A Teleop Swerve Drive Subsystem
- Not read yet:Mini-Project: An Autonomous Routine with PathPlanner
- Not read yet:Mini-Project: Vision-Aligned Scoring with Limelight
12 / common-mistakes-troubleshooting
13 / advanced-techniques-case-studies
- Not read yet:State-Space Control and Kalman Filtering
- Not read yet:Log Replay Architecture with AdvantageKit
- Not read yet:Advanced Pose Estimation: Multi-Tag Fusion and Standard Deviations
- Not read yet:Robot Coordination, Alerts, and Operator Feedback
- Not read yet:Case Study: Hardening Software Before an Event