View Single Post
  #13   Spotlight this post!  
Unread 02-02-2004, 22:42
Guest
 
Posts: n/a
Angry Re: using single solenoid like a double

Quote:
Originally Posted by velocipenguin
If you do it this way, it should only toggle the relay output when the button transitions from one state to another. That should eliminate the problem of infinite toggling that was present in my last suggestion.

Code:
// declare this as a global variable
bool LastButtonValue=0;
 
// place the following within the main loop
if(p1_sw_trig!=LastButtonValue)
relay1_fwd ^= p1_sw_trig;
 
LastButtonValue = p1_sw_trig;
umm... that's exactly what's in the repository link above .....