View unanswered posts | View active topics It is currently Sat Jun 23, 2018 12:21 am

 Page 1 of 1 [ 3 posts ]
 Print view Previous topic | Next topic
brand new, channel 5 and 6 help?
Author Message
Rookie

Joined: Wed Oct 10, 2012 11:01 pm
Posts: 1
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!

Wed Oct 10, 2012 11:10 pm

Joined: Thu May 24, 2012 12:15 pm
Posts: 722
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 updated help documentation and the ROBOTC Forums.

Thu Oct 11, 2012 4:41 pm
Rookie

Joined: Thu May 31, 2012 4:06 pm
Posts: 25
Location: Pittsburgh, Pa
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

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
Display posts from previous:  Sort by
 Page 1 of 1 [ 3 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