View Single Post
  #6   Spotlight this post!  
Unread 02-02-2004, 21:17
Guest
 
Posts: n/a
Re: using single solenoid like a double

Quote:
Originally Posted by deltacoder1020
if you mean you want to use two buttons like "on" and "off" buttons, here's one way to do it:

Code:
static char btn_status = 0;

if(p1_sw_aux1) btn_status = 1;
if(p1_sw_aux2) btn_status = 0;

relay1_fwd = btn_status;
basically, just declare a static variable (so that it holds its state), then use the input from the buttons to set the variable at the appropriate times. (note - some of the input variable names may be off, i'm doing this from memory only)
The code needs to be made slightly more complex because, as I interpret it, SteveO wants one button to toggle, my code above solves that.