View Single Post
  #1   Spotlight this post!  
Unread 19-02-2004, 06:50
Ryan M. Ryan M. is offline
Programming User
FRC #1317 (Digital Fusion)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Ohio
Posts: 1,508
Ryan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud of
Re: Getting the relays to stay constant

Do something like this:
Code:
unsigned char state = 0;
unsinged char switchState = 0;

// Check switches. Substitute switch for whatever switch on the OI you are using
// I use the switch state to prevent the switching of the state do to not realeasing the button right away
if(switch && !switchState)
{
    // Set switch state
    swtichState = 1;

    // Switch states
    if(switch)
        state = 0;
    else
        state = 1;
}
else if(!switch)
{
    // reset the switch state
    switchState = 0;
}

// Subitute relay with your relay
if(state)
{
     // Run forward
     relay_fwd = 1;
     relay_rev = 0;
}
else
{
    // Turn off relay
    relay_fwd = 0;
    relay_rev = 0;
}
Put that whole thing where ever you are doing your cheking currently. Put the varable declarations at the top of whatever function you have this in. That should work. (I hope... )
__________________