View unanswered posts | View active topics It is currently Fri Apr 10, 2020 2:16 pm

 Page 1 of 1 [ 2 posts ]
 Print view Previous topic | Next topic
ROBOTC Natural Language programming help
Author Message
Rookie

Joined: Wed Jan 21, 2015 5:50 pm
Posts: 1
ROBOTC Natural Language programming help
Hey I'm having the same problem (along with many others)

This is my Code:

 Code:task main (){  int threshold = 18;             /* Int 'threshold' will allow us to ignore low       */                                  /* readings that keep our robot in perpetual motion. */  while(true)                            // Infinite loop:  {    getJoystickSettings(joystick);    if(abs(joystick.joy1_y2) > threshold)   // If the right analog stick's Y-axis readings are either above or below the threshold:    {      motor[right] = joystick.joy1_y2;         // Motor B is assigned a power level equal to the right analog stick's Y-axis reading.    }    else                                    // Else if the readings are within the threshold:    {      motor[right] = 0;                        // Motor B is stopped with a power level of 0.    }    if(abs(joystick.joy1_y1) > threshold)   // If the left analog stick's Y-axis readings are either above or below the threshold:    {      motor[left] = joystick.joy1_y1;         // Motor C is assigned a power level equal to the left analog stick's Y-axis reading.    }    else                                    // Else if the readings are within the threshold:    {      motor[left] = 0;                        // Motor C is stopped with a power level of 0.    }    if(abs(joy1Btn(5));    {       motor[arm] = 50;    }    else    {       motor[arm] = 0;    }    if(abs(joy1Btn(6));    {       motor[arm] = -50;    }    else    {       motor[arm] = 0;    }    if(abs(joy1Btn(2));    {       servo[claw] = 25;    }    else    {       servo[claw] = 0;    }    if(abs(joy1Btn(3));    {       servo[claw] = -25;    }    else    {       servo[claw] = 0;    }    if(abs(joy1Btn(1));    {       servo[tail] = -20;    }    else    {       servo[tail] = 0;    }    if(abs(joy1Btn(4));    {       servo[tail] = -20;    }    else    {       servo[tail] = 0;    }    if(abs(joy1Btn(7));    {       servo[wrist] = 30;    }    else    {       servo[wrist] = 0;    }    if(abs(joy1Btn(8));    {       servo[wrist] = -30;    }    else    {       servo[wrist] = 0;

Wed Jan 21, 2015 5:53 pm

Joined: Thu May 24, 2012 12:15 pm
Posts: 722
Re: ROBOTC Natural Language programming help
I have split this topic into it's own thread as the previous thread was quite old and hadn't had a response in almost 4 (!) years. Please refrain from resurrecting threads that old in the future as this will help avoid any confusion.

Is the code posted the entirety of your program? If so, you are missing the closing braces } on your last else statement and also on task main. This will generate the '**Error**:Executable statements not valid in 'main' declaration block' error message.

You are also most likely experiencing motors that are twitching when you press a button to control them. This is because there are multiple if/else statements controlling one motor; they essentially cancel each other out when a button is pressed. For a more in-depth explanation, please see my previous comments on this type of scenario in this thread: viewtopic.php?f=11&t=5610&p=23298&hilit=remote+control#p23298

Please let us know if this helps resolve the issue for you.

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our updated help documentation and the ROBOTC Forums.

Wed Jan 21, 2015 6:17 pm
Display posts from previous:  Sort by
 Page 1 of 1 [ 2 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

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.