View Single Post
  #4   Spotlight this post!  
Unread 02-15-2015, 06:33 PM
nandeeka's Avatar
nandeeka nandeeka is offline
Registered User
FRC #1868
Team Role: Programmer
 
Join Date: May 2014
Rookie Year: 2013
Location: United States
Posts: 53
nandeeka is on a distinguished road
Re: Limit switch help

Try something like this:

Code:
#include "WPILib.h"


class Robot: public SampleRobot
{
	Talon Motor;
    DigitalInput limitSwitch;

public:
	 Robot():

	limitSwitch(1),
	Motor(6)

	{

	}

	 

	void OperatorControl()
	{
		while (IsOperatorControl() && IsEnabled())
		{
         	      if(limitSwitch.Get()) {
			     Motor.Set(1.0);
                             Wait(0.005);
                      }
                 }

	}

};

START_ROBOT_CLASS(Robot);
limitSwitch.Get() returns a boolean (true if the limit switch is pressed, false if it isn't). If you want it to move when the limit switch is pressed, then you want to move when the get method is returning true.
Reply With Quote