View unanswered posts | View active topics It is currently Fri Feb 27, 2015 7:42 am






Reply to topic  [ 2 posts ] 
ROBOTC Natural Language programming help 
Author Message
Rookie

Joined: Wed Jan 21, 2015 5:50 pm
Posts: 1
Post 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
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 662
Post 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 Wiki and our Forums.

I just met you,
And this is crazy,
But here's my code now,
So fix it, maybe?
~ Carly Rae Jepsen parody


Wed Jan 21, 2015 6:17 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


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

Search for:
Jump to:  



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