Lesson: Intro to Sensors

Explore the sensors used on the FRC platform and the basics of how they are programmed.

Gain a basic understanding of the sensors available on the FRC platform and how they are programmed.


Sensors are hardware devices used to gain information about the robot environment or operation. There is a large number of devices available as FRC can use any device in the world as long as you can interface it to the RoboRio. We are going to discuss some of the commonly used ones.

Limit Switch. Limit switches are simple mechanical devices that are used to sense mechanical motion. The limit switch has an arm on it that is contacted by some moving part of a robot and the switch returns a true/false indication. You use the WpiLib DigitalInput class with limit switches which are wired to RoboRio digital input ports.

Hall Effect Sensor. A Hall Effect sensor is similar to a limit switch but does not physically contact the moving robot part. You mount the sensor on a fixed part of the robot and a magnet on the moving part and when the magnet passes close to the sensor it will report that in the same way a limit switch would. Use the DigitalInput class and wire to a digital input port.

Encoder. An encoder is a device that you attach to the end of a rotating shaft to measure the revolutions and direction of that shaft. Use the Encoder class and wire to a digital input port. Note that encoders may need two ports to sense direction or increase resolution. Typically used to determine how far your robot has travelled.

Magnetic Encoder. Same as an encoder but senses a magnet on the shaft instead of using a physical connection.

UltraSonic Distance Sensor. Uses ultrasonic sound waves to measure distance to an object. Use the UltraSonic class for some sensors and the analog input class for others.

Light Sensor. Measures light falling on the sensor. There are forms of the sensor that you connect to a digital input port and the sensor acts as an on/off sensor and there are forms that return a measurement of the light and you would use an analog input port to obtain the light reading.

Gyroscope. Measures change in direction of travel of a robot. Use the AnalogGyro class and connect the Gyro to analog input port 0 or 1 (these ports specifically know how to handle gyro input).

Camera. A hallmark of FRC competition and engineering is the use of computer vision. Every game has a vision target of some kind in the game. You can use cameras connected to the RoboRio to collect images and then process those images to locate the target. With that information you can navigate your robot as appropriate. Vision processing is a large and complex subject with different ways to implement it. There is quite a lot of information available online. We expect to add a vision processing lesson during the 2017 season when the new Grip vision processing system is released to teams.


Lesson navigation: