View Single Post
  #4   Spotlight this post!  
Unread 02-02-2007, 13:26
Racer26 Racer26 is offline
Registered User
no team
Team Role: Alumni
 
Join Date: Apr 2003
Rookie Year: 2003
Location: Beaverton, ON
Posts: 2,229
Racer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond repute
Re: making a trigger a toggle

well, if you're trying to turn a motor/solenoid/whatever else on/off only, without variable speed, i would use a spike. the code is simple.

Code:
static char trigold = 0; // Define this with global scope

if(p1_sw_trig == 1 && trigold == 0){
       relay1_fwd = !relay1_fwd;
}

trigold = p1_sw_trig;
That should toggle relay1's fwd direction each time there is a 0->1 transition on the port 1 trigger.