View unanswered posts | View active topics It is currently Wed Oct 16, 2019 7:48 am






Reply to topic  [ 2 posts ] 
Using VEX controller to send multiple commands 
Author Message
Rookie

Joined: Tue Feb 10, 2015 6:16 pm
Posts: 2
Post Using VEX controller to send multiple commands
Is it possible to use the controller button to run a specific command sequence on the robot? For example, if I press a button or a button sequence on the controller, can it broadcast and trigger an event in the ModKit language?

Thanks in advance.


Wed Feb 11, 2015 7:23 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 722
Post Re: Using VEX controller to send multiple commands
Yes it can; are you using the text-based ROBOTC or Graphical ROBOTC programming environment? The process will be slightly different depending on which interface you are using, but the code will remain the same.

Graphical option:

Image

Text-based option:

Code:
#pragma config(Sensor, port2,  touchLED,       sensorVexIQ_LED)
#pragma config(Sensor, port3,  colorDetector,  sensorVexIQ_ColorHue)
#pragma config(Sensor, port4,  gyroSensor,     sensorVexIQ_Gyro)
#pragma config(Sensor, port7,  distanceMM,     sensorVexIQ_Distance)
#pragma config(Sensor, port8,  bumpSwitch,     sensorVexIQ_Touch)
#pragma config(Motor,  motor1,          leftMotor,     tmotorVexIQ, openLoop, driveLeft, encoder)
#pragma config(Motor,  motor6,          rightMotor,    tmotorVexIQ, openLoop, reversed, driveRight, encoder)
#pragma config(Motor,  motor10,         armMotor,      tmotorVexIQ, openLoop, encoder)
#pragma config(Motor,  motor11,         clawMotor,     tmotorVexIQ, openLoop, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//


task main()
{
   repeat (forever) {
      tankControl(ChD, ChA, 10);
      if (getJoystickValue(BtnEUp) == 1) {
         // The robot will perform whatever actions you want
         // When button EUp is pressed (has a value of 1)
      }
   }
}


This is a very basic implementation that uses Button E-Up; you will need to replace the comments (marked with the green // marks) with the code you want to run when that button is pressed.

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our updated help documentation and the ROBOTC Forums.


Mon Feb 16, 2015 12:55 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.