View unanswered posts | View active topics It is currently Tue May 21, 2019 2:31 am

 Page 1 of 1 [ 3 posts ]
 Print view Previous topic | Next topic
Help on determining the cause for this non-functioning code
Author Message
Rookie

Joined: Tue Nov 10, 2015 11:47 pm
Posts: 4
Help on determining the cause for this non-functioning code
 Code:while(SensorValue(IR) == 5)   {      motor[motorC] = 60;      wait1Msec(2000);      while(SensorValue(compass) < 205 && SensorValue(compass) > 235)      {         motor[motorB] = 30;         motor[motorC] = -20;      }      motor[motorB] = 60;      motor[motorC] = 60;   }

Any help would be greatly appreciated thank you.

Wed Nov 11, 2015 12:18 am
Rookie

Joined: Tue Nov 10, 2015 11:53 pm
Posts: 2
Re: Help on determining the cause for this non-functioning c
Hello, bonglord.

I believe your problem is to do with this line of code: "while(SensorValue(compass) < 205 && SensorValue(compass) > 235)"
It's impossible for a number to be smaller than 205 and larger than 235 at the same time! Instead of using AND (&&), use OR (||), like so:

 Code:while(SensorValue(IR) == 5)   {      motor[motorC] = 60;      wait1Msec(2000);      while(SensorValue(compass) < 205 || SensorValue(compass) > 235)      {         motor[motorB] = 30;         motor[motorC] = -20;      }      motor[motorB] = 60;      motor[motorC] = 60;   }

Hope that helps!

Last edited by WhoIsThisForChan on Wed Nov 11, 2015 12:29 am, edited 2 times in total.

Wed Nov 11, 2015 12:23 am
Rookie

Joined: Tue Nov 10, 2015 11:47 pm
Posts: 4
Re: Help on determining the cause for this non-functioning c
Thanks for the help Chan.

I've implemented your changes and it's all working perfectly now

Wed Nov 11, 2015 12:29 am
Display posts from previous:  Sort by
 Page 1 of 1 [ 3 posts ]

#### Who is online

Users browsing this forum: No registered users and 2 guests

 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    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    2014 Robotics Academy Summer of Learning