Go to Post No matter what you do and how well you try to protect them, some people are just out there to be candidates for the Darwin Awards! - Jay H 237 [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 Rating: Thread Rating: 6 votes, 4.33 average. Display Modes
Prev Previous Post   Next Post Next
  #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
 


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:48.

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