View Single Post
  #7   Spotlight this post!  
Unread 27-02-2014, 13:49
RyanCahoon's Avatar
RyanCahoon RyanCahoon is offline
Disassembling my prior presumptions
FRC #0766 (M-A Bears)
Team Role: Engineer
 
Join Date: Dec 2007
Rookie Year: 2007
Location: Mountain View
Posts: 689
RyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond repute
Re: FTC Block Party IR-Sensor

That would definitely work, and there's no problem with that, but you would need to have two identical else {} blocks (one on each of the two if statements) so that the "move on to next bucket" code would be run if either of the conditions was false.

An easier way to do this is to use the "and" operator to combine both if statements. In ROBOTC, you write this as &&

Code:
task main()
{
   if (conditional1(sensor)==2 && conditional2(sensor) > 100)
   {
      //run bucket commands
   }
   else
   {
      //move on to next bucket
   }
}
__________________
FRC 2046, 2007-2008, Student member
FRC 1708, 2009-2012, College mentor; 2013-2014, Mentor
FRC 766, 2015-, Mentor

Last edited by RyanCahoon : 27-02-2014 at 14:06.