ROBOTC.net forums
http://www.robotc.net/forums/

Using VEX controller to send multiple commands
http://www.robotc.net/forums/viewtopic.php?f=14&t=10520
Page 1 of 1

Author:  thitsa [ Wed Feb 11, 2015 7:23 pm ]
Post subject:  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.

Author:  JohnWatson [ Mon Feb 16, 2015 12:55 pm ]
Post subject:  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.

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