View Single Post
  #58   Spotlight this post!  
Unread 18-03-2004, 08:42
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: quick question: TIMERS

Quote:
Originally Posted by Xufer
...how would i do it if i was to have like 4 auton modes...
You have a couple of options. Simplest in your case would probably be to do something like this:
Code:
// somehow get a number in the "auto" variable
  auto = (rc_dig_in18<<2) | (rc_dig_in17<<1) | (rc_dig_in16);
// or whatever it takes to turn your switches into a value
  if (auto==1)
  {
    // code for mode 1
  }
  if (auto==2)
  {
    // code for mode 2
  }
  // etc.
It might theoretically be more efficient to use a switch/case statement instead of a string of ifs, but you probably have enough to focus on right now without worrying about learning another control structure.