View unanswered posts | View active topics It is currently Tue Oct 21, 2014 12:02 am






Reply to topic  [ 1 post ] 
Code for Remotely Controlling your Cortex 
Author Message
Site Admin
Site Admin

Joined: Tue May 15, 2007 9:02 am
Posts: 405
Post Code for Remotely Controlling your Cortex
Below is sample code for steering your robot and controlling and arm. Driving motors are configured in motor ports 2 and 3. The motor for the arm is configured for motor port 6.

Code:
#pragma config(Motor,  port2,           rightMotor,    tmotorNormal, openLoop, reversed)
#pragma config(Motor,  port3,           leftMotor,     tmotorNormal, openLoop)
#pragma config(Motor,  port6,           armMotor,      tmotorNormal, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{

  while(1 == 1) //Create an infinite loop, enabling remote control indefinitely
  {
    motor[leftMotor] = vexRT[Ch3];  //Set the left motor power equal to the left joystick vertical axis
    motor[rightMotor] = vexRT[Ch2]; //Set the right motor power equal to the right joystick vertical axis

    if(vexRT[Btn6U] == 1)     //If the group 6 Up button is pressed...
    {
      motor[armMotor] = 40;   //...then raise the arm.
    }
    else if(vexRT[Btn6D] == 1)//But if the group 6 down button is pressed...
    {
      motor[armMotor] = -40;  //...then lower the arm.
    }
    else                      //But if no button is pressed...
    {
      motor[armMotor] = 0;    //...stop the arm.
    }
   
  }

}

_________________
Jesse Flot
CMU Robotics Academy
ROBOTC Support


Fri Sep 03, 2010 9:48 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 1 guest


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.