View unanswered posts | View active topics It is currently Thu Aug 21, 2014 5:59 pm






Reply to topic  [ 3 posts ] 
brand new, channel 5 and 6 help? 
Author Message
Rookie

Joined: Wed Oct 10, 2012 11:01 pm
Posts: 1
Post brand new, channel 5 and 6 help?
I am brand new to the world of RobotC and am using a vex cortex microcontroller and vexnet remote control. the video tutorials were great, and showed me how to program for the joysticks, however, I am building a vertical ascension robot and i want a simple up/down robot and would like to use the u/d buttons at the top. i need two motors to move in the opposite direction simultaneously at full power (one at 127, the other at -127) all help would be really appreciated!! thanks much!
:bow: :bow: :bow: :bow: :bow: :bow: :bow: :bow: :bow: :programmer:


Wed Oct 10, 2012 11:10 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 564
Post Re: brand new, channel 5 and 6 help?
It really does depend on what exactly you are trying to accomplish, how your robot is set up, etc, but a very basic if/else if statement should suffice;

Code:
task main()
{
   while (true)
      {
         
      if(vexRT[btn6U] == 1) //Button 6 up is pressed, move lift up
         {
         motor[port1] = 127;
         motor[port2] = -127;
         }
     
     else if(vexRT[btn6D] == 1) //Button 6 down is pressed, move lift down
        {
           motor[port1] = -127;
           motor[port2] = 127;
        }
        
     else //If neither is pressed, stop motors
        {
           motor[port1] = 0;
           motor[port2] = 0;   
        
        }
     }
}


You will need to have the code inside of a while loop so it continually checks for the Joystick button presses. If the 6 Up button is pressed, it will turn on the motors in ports 1 and 2 in one direction; if the 6 Down button is pressed it will turn them on the opposite direction; if neither is pressed the motors will be turned off.

As a side note, I suggest configuring the motors in the Motors and Sensors Setup window (reversing motors as necessary) to avoid having to use a negative sign to move a motor 'forward' or 'up'. It will make the code much simpler to implement and read, because (when configured properly) you will be able to use positive values on on the motors to move forward/up and negative values to move backwards/down without having to remember which ones are flipped.

_________________
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


Thu Oct 11, 2012 4:41 pm
Profile
Rookie

Joined: Thu May 31, 2012 4:06 pm
Posts: 22
Location: Pittsburgh, Pa
Post Re: brand new, channel 5 and 6 help?
This is the same code as above with some changes. Motors are 269s in ports 2 and 3.
Code:
#pragma config(Motor,  port2,           motor1,        tmotorVex269, openLoop)
#pragma config(Motor,  port3,           motor2,        tmotorVex269, openLoop, reversed)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
   while (true)
   {
      if(vexRT[btn6U] == 1 && vexRT[btn6D] == 0)     //I always check to see if the other button is not pressed
      { motor[port1] = 127;
         motor[port2] = 127;
      }
      else if(vexRT[btn6D] == 1 && vexRT[btn6U] == 0)
      {
         motor[port1] = -50;                          //if going dowm it will most likely not need full power
         motor[port2] = -50;
      }
      else
      {
         motor[port1] = 0;
         motor[port2] = 0;
      }
   }
}

What do you think?

_________________
SHARP
Sarah Heinz Advanced Robotics Program

VEX 889A and FIRST 3260

Pittsburgh Champions Aerial Assist 2014
Pittsburgh and Buckeye Finalist Ultimate Ascent 2013
Toss Up Champions and Excellence-Pittsburgh
Toss Up Champions-Northwest Maryland VRC


Thu Oct 11, 2012 5:34 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

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.