|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
for easy C,
i know you can set a relay to a button and have that relay in a set position when you hold the button, but can you, in easy c, have it so you click the button once and the relay stays on, and click it again to switch the relay reverse or off? i know the wording of this question is not too great, but if you can decipher it, an answer would be great! |
|
#2
|
|||
|
|||
|
Re: Easy C Relay Programming
You want the relay to toggle. Its not too complicated to do.
This example will toggle a relay when the trigger is pulled on the first joystick. Code:
char relayPos = 0; //Holds the current position of the relay
char relayRelease = 1; //Holds if trigger has been released yet
if(GetOIDInput(1, 1) && relayRelease) //If trigger is pressed after being released
{
if(relayPos == 1)
{
SetRelay(1, 0, 1);
relayPos = 0;
}else
{
SetRelay(1, 1, 0);
relayPos = 1;
}
relayRelease = 0; //Set trigger as pressed
}else if(GetOIDInput(1, 1)==0) //trigger released
{
relayRelease = 1;
}
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Pneumatics (Spike Relay, Solenoid etc.) Programming | oceansidehs | Programming | 8 | 10-02-2007 13:58 |
| Easy C programming Problem | fredliu168 | FIRST Tech Challenge | 6 | 19-11-2006 22:44 |
| Relay Programming Questions... | comwiz7 | Programming | 11 | 21-02-2006 13:04 |
| Easy C programming , Worth teaching? | Nine9cracker | Programming | 16 | 19-01-2006 00:45 |
| Easy-C Programming CD | Jeff K. | Programming | 2 | 09-01-2006 02:20 |