FIRST Robotics Competition Blog

Community Browser
cancel
Showing results for 
Search instead for 
Did you mean: 

Use a Limit Switch to Control a Servo Motor Snippet

Whit-E_Wall-E
NI Employee (retired)

Digital inputs, such as a limit switch, can be used to control movement of your servos.  To do this, wire a limit switch to a digital input on your cRIO, then use the digital input as control for a case structure.  Case structures allow your program to execute code depending upon certain conditions.  In this snippet, the case structure will move your servo motors when the switches are pressed.  The example code below shows two case structures, the first will move the servo motor forward to 180 degrees when one limit switch is pressed, the second case structure will move the servo backward to 0 degrees when another limit switch is pressed.

Looking for more information on sensor programing?  Check out these online tutorials about the basics of sensor programming and sensor fusion.

Digital+Input+Case+Structure+Control.png

Regards,

M. Whitaker
ni.com/support