View unanswered posts | View active topics It is currently Sun Feb 14, 2016 9:30 am

 Page 1 of 1 [ 3 posts ]
 Print view Previous topic | Next topic
Help With An Autonomous Programming Problem
Author Message
Rookie

Joined: Wed Jan 16, 2013 4:45 pm
Posts: 2
Help With An Autonomous Programming Problem
Hi Everybody,
I have been recruited as a programmer for my school robotics team for the upcoming robotics ring it up competition. I have been programming the autonomous portion of the competition and have everything working except for one last thing. First Heres the basics of our program so you can understand the problem. Basically there are 3 positions that our bot could potentially have to drive to, so we decided that the easiest way forward would be to have 3 sets of preset instructions for the bot to drive to and it would use the IRSeeker to decide which set of instructions to run. So basically if the seeker detects the bot is to the left, do this, if its to the right, do this, and if its straight ahead of you do this. This all should work fine in theory but the problem is I dont know how to say IF you detect the sensor is to the right (for example) THEN and NOTHING ELSE. The problem is the sensor will detect the signal is to the right start moving and then detect the sensor is straight ahead or to the left and try to do that set of instructions. So how do I tell my sensor IF this THEN that but ONLY that and forget the rest of the code?

Wed Jan 16, 2013 4:57 pm
Novice

Joined: Sun Oct 21, 2012 10:01 pm
Posts: 76
Re: Help With An Autonomous Programming Problem
I think you're looking for the else-if statement.

 Code:task main(){   waitForStart();   wait10Msec(20); // Wait a little.        int IRVal = SensorValue(IRSeeker);      if (IRVal < 5)   {      // All driving code for left column     }   else if (IRVal > 5)   {      // All driving code for right column   }   else   {      // All driving code for center   }}

Wed Jan 16, 2013 5:47 pm
Rookie

Joined: Wed Jan 16, 2013 4:45 pm
Posts: 2
Re: Help With An Autonomous Programming Problem
Well, I guess I just thought that would do the exact same thing as \
 Code:   If   {      // All driving code for left column     }   if (IRVal > 5)   {      // All driving code for right column   }   if   {      // All driving code for center   }}

But that seems to work for me so far, thank you SO much, should of tried that earlier.

Wed Jan 16, 2013 6:17 pm
Display posts from previous:  Sort by
 Page 1 of 1 [ 3 posts ]

#### Who is online

Users browsing this forum: hthelosen and 1 guest

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    2014 Robotics Academy Summer of Learning    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge