View Single Post
  #9   Spotlight this post!  
Unread 04-10-2016, 08:42 PM
Brian Ho Brian Ho is offline
Registered User
FRC #4343 (MaxTech)
Team Role: Mentor
 
Join Date: Nov 2012
Rookie Year: 2012
Location: Canada
Posts: 4
Brian Ho is an unknown quantity at this point
Re: Limit Switch Programming

Quote:
Originally Posted by GoldenGollem View Post
First off, thanks Engunner for the idea of using booleans to organize the code. I am using one limit switch to stop the motor from moving too far in the reverse. I am, however having issues with
Code:
if (intakeMotorForward && !limitSwitch ) {
It is showing that there is and error there.
There are 2 simple problems with your code.

First,
On top, where you declared
Code:
DigitalInput limitSwitch;
change to
Code:
DigitalInput limitSwitch = new DigitalInput(x);
where x is the port number where your limit switch is plugged in at the DIO part of the roborio

Second,
It's not just
Code:
!limitSwitch
You need to use
Code:
!limitSwitch.get()
Which gets you the boolean value of the limit switch which may be true or false depending if you wired it as normally opened or normally closed.
Reply With Quote