View Single Post
  #1   Spotlight this post!  
Unread 29-05-2012, 13:13
RoastBeefer RoastBeefer is offline
Registered User
FRC #3055
 
Join Date: May 2012
Location: Hell
Posts: 5
RoastBeefer is an unknown quantity at this point
Java Toggle Button

Hello, we have a conveyor belt powered by a motor on our bot. We want to press a button and make it run until we press the same button again. We cannot figure out how to do this. Here is what we currently have for our code:
Code:
 //Conveyor Belt
       boolean belt = false;
       conveyorMotor.set(0);
       if(belt == false){
           if(stick.getRawButton(3)){
               belt = true;
               conveyorMotor.set(1);    
           }
           else if(belt == true){
               if(stick.getRawButton(3)){
               belt = false;
               conveyorMotor.set(0);    
               }              
           }
Currently this only turns on the belt while pressed and stops as soon as we let go. I feel like we're taking the totally wrong approach to this. Please help
Reply With Quote