View Single Post
  #12   Spotlight this post!  
Unread 02-02-2004, 22:10
velocipenguin velocipenguin is offline
Registered User
#0246 (Overclocked)
Team Role: Programmer
 
Join Date: Feb 2004
Location: Boston, MA
Posts: 77
velocipenguin is on a distinguished road
Send a message via AIM to velocipenguin
Re: using single solenoid like a double

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;