|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Getting the relays to stay constant
Right now we have our pump hooked up to one of the spikes on #5 and while it works (press a button and it goes on) it doesn't stay on and it's really annoying to have to hold it down.
I think* (i don't know how to code and no one on the team does) that all I have to do is something like this when joystick button is depressed set a variable equal to one then do an if statement, if variable equals 1 to set the relay to fwd, else if, set relay to neutral position i guess fwd and rev are equal to zero? I don't know the proper syntax or way about doing this, but i think it would only be a 1 or 2 lines of code could anyone tell me how to do it or write it out so I could just copy and paste it into our code? plzzzz It's #5 if you want to write it out |
|
#2
|
||||
|
||||
|
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;
}
) |
|
#3
|
|||
|
|||
|
Re: Getting the relays to stay constant
Quote:
relay8rev = !digitalinput18; those names area ll wrong because I dont have code with me, but what it does is set the relay to the opposite value of the digital input sensor (in this case, the preasure switch). If the swith is 1 (it's up to preasure) the relay is off. If it's below presure (0), then the relay will fire up (to 1). Hope you can learn something from this. ~Bstempi |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| stay on the carpet????!!!! | soap108 | Rules/Strategy | 12 | 13-03-2003 12:50 |
| SPIKE relays | Andy Brockway | Electrical | 2 | 13-11-2002 13:22 |
| where are teams going to stay? | archiver | 2001 | 2 | 24-06-2002 02:49 |
| How many hotels did you team stay at?? | Elgin Clock | Championship Event | 4 | 10-05-2002 17:53 |
| How do you control relays | BinaryBob0001 | Technical Discussion | 2 | 21-01-2002 08:42 |