View Single Post
  #11   Spotlight this post!  
Unread 23-01-2008, 09:12
Spartan151's Avatar
Spartan151 Spartan151 is offline
TCU Bound (Class of 2013)
AKA: Sean
FRC #2920
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Holly Springs, MS
Posts: 86
Spartan151 will become famous soon enough
Re: A New Programmer

Quote:
Originally Posted by Alan Anderson View Post
Examples of toggle functions are common on the Chief Delphi forums. Here's another:
Code:
  :
  :
  static char prev_trig = 0;
  static char toggle = 0;
  :
  if (p1_trig && !prev_trig)
  {
    toggle = !toggle;
  }
  prev_trig = p1_trig;
  :
This will switch toggle from 0 to 1, or vice versa, each time the port 1 joystick trigger is depressed. You can test its value to decide what to do next.
Okay. Taking this code, where do I write in the relay values, if they need to be written in? Or is that done with the previous code for the relay values?