Go to Post Gracious Professionalism at its finest - Competing like CRAZY on the field, then working together like professionals off the field to make these events the best they can be for everyone involved. - Stu Bloom [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 02-04-2015, 05:16 PM
curtis0gj curtis0gj is offline
Registered User
FRC #5033 (Beavertronics)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Canada
Posts: 121
curtis0gj will become famous soon enough
Limit Swtich Help

Hi guys, our team is trying to use a limit switch to stop the lifting mech powered by 2 victor motor controllers from bottoming out or flying off the top. But I can't get the switch to work properly.

Code:
public class Robot extends SampleRobot {
	
    RobotDrive robot;
    Joystick stick;
    Joystick xbox;

    Victor victor1;
    Victor victor2;
    DigitalInput limit;
    
    
    boolean limitPressed = false;

    boolean buttonPressedForwardVictor = false;

public Robot() {
    	
    	robot = new RobotDrive(0, 1);
        stick = new Joystick(1);
        xbox = new Joystick(0);

        limit = new DigitalInput(4);	
        
        victor1 = new Victor(4);
        victor2 = new Victor(5);
 
    }

public void operatorControl() {
    	
    	while (isOperatorControl() && isEnabled()) {
        	
            stick.getThrottle();
            robot.arcadeDrive(stick.getY(), stick.getX());
            Timer.delay(0.1);
     
            if(limit.get()) {
            	
            	limitPressed = true;
            	
            }
            
            if(limitPressed = true) {
            	
            	victor1.set(0);
            	victor2.set(0);
            	
            }
            
            if (xbox.getRawButton(4)) {
            	
            	victor1.set(1);
            	victor2.set(1);
            	buttonPressedForwardVictor = true;
            	
            } else if (buttonPressedForwardVictor = true) {
            	
            	victor1.set(0);
            	victor2.set(0);
            	buttonPressedForwardVictor = false;
            } 
            
            if (xbox.getRawButton(1)) {
            	
            	victor1.set(-1);
            	victor2.set(-1);
            }
            
            	
            }
            
    	}
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 08:44 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi