ROBOTC.net forumshttp://robotc.net/forums/ brand new, channel 5 and 6 help?http://robotc.net/forums/viewtopic.php?f=11&t=4970 Page 1 of 1

 Author: soccergurl63 [ Wed Oct 10, 2012 11:10 pm ] Post subject: 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!

Author:  JohnWatson [ Thu Oct 11, 2012 4:41 pm ]
Post subject:  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.

Author:  Kevin Selavko [ Thu Oct 11, 2012 5:34 pm ]
Post subject:  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?

 Page 1 of 1 All times are UTC - 5 hours [ DST ] Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Grouphttp://www.phpbb.com/