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

Problems with the Logitech Remote
http://www.robotc.net/forums/viewtopic.php?f=55&t=12536
Page 1 of 1

Author:  FigueroaG [ Wed Nov 18, 2015 11:15 am ]
Post subject:  Problems with the Logitech Remote

How do i code this in a way that the Logitech remote can read?




#pragma config(Sensor, in6, armPot, sensorPotentiometer)
#pragma config(Sensor, dgtl6, frontLimit, sensorTouch)
#pragma config(Motor, port2, rightMotor, tmotorServoContinuousRotation, openLoop, reversed)
#pragma config(Motor, port3, leftMotor, tmotorServoContinuousRotation, openLoop)
#pragma config(Motor, port6, armMotor, tmotorServoContinuousRotation, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

task main()
{

ClearTimer(T1)
while (time1[T1] < 90000)
{
motor[leftMotor] = vexRT[Ch3] / 2;
motor[rightMotor] = vexRT[Ch2] / 2;

if(vexRT[Btn6U] == 1 && SensorValue[armPot] < 645)
{
motor[armMotor] = 40;
}
else if(vexRT[Btn6D] == 1 && SensorValue [frontLimit] == 0)
{
motor[armMotor] = -40;
}
else
{
motor[armMotor] = 0;
}
}

motor[leftmotor] = 0;
motor[rightmotor] = 0;

}

Author:  Tabor473 [ Sat Nov 21, 2015 7:32 pm ]
Post subject:  Re: Problems with the Logitech Remote

So I would suggest looking at the remote control sample programs inside of ROBOTC. Here is one of them

Code:
#pragma config(StandardModel, "RVW SQUAREBOT")
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

/*+++++++++++++++++++++++++++++++++++++++++++++| Notes |++++++++++++++++++++++++++++++++++++++++++++++
2 Joystick Drive with Thresholds
- This program allows you to remotely control your robot using the USB Logitech Dual
  Action Joysticks.
- This program also ignores low values that would cause your robot to move when the joysticks fail to
  return back to exact center.  You may need to adjust the 'threshold' value to get it just right.
- For USB values to be transmitted to the robot, you must follow several steps:
  - Use the "#include "JoystickDriver.c"" line at the beginning of your program
  - Call the "getJoystickSettings(joystick);" in a loop to repeatedly retrieve the latest values
  - Open the Robot > Debugger Windows > "Joystick Control - Basic" window after downloading your
    program to the virtual robot

Robot Model(s): Squarebot

[I/O Port]          [Name]              [Type]                [Description]
Motor Port 2        rightMotor          VEX Motor             Right side motor
Motor Port 3        leftMotor           VEX Motor             Left side motor

*To run this sample program on Swervebot, be sure to Reverse Motor Port 3 in the Motors and Sensors
 Setup, and to make sure that Motor Port 2 is NOT Reversed.
----------------------------------------------------------------------------------------------------*/

#pragma debuggerWindows("joystickSimple");
#include "JoystickDriver.c"

task main()
{
  //Integer variable that allows you to specify a "deadzone" where values (both positive or negative)
  //less than the threshold will be ignored.
  int threshold = 10;

  //Loop Forever
  while(1 == 1)
  {
    //Get the Latest joystick values
    getJoystickSettings(joystick);
    if(abs(joystick.joy1_y2) > threshold)     // If the right analog stick's Y-axis readings are either above or below the threshold...
    {
      motor[rightMotor] = joystick.joy1_y2;   // ...the right motor is assigned a power level equal to the right analog stick's Y-axis reading.
    }
    else                                      // Else the readings are within the threshold, so
    {
      motor[rightMotor] = 0;                  // ...the right motor is stopped with a power level of 0.
    }


    if(abs(joystick.joy1_y1) > threshold)     // If the left analog stick's Y-axis readings are either above or below the threshold...
    {
      motor[leftMotor] = joystick.joy1_y1;    // ...the left motor is assigned a power level equal to the left analog stick's Y-axis reading.
    }
    else                                      // Else if the readings are within the threshold...
    {
      motor[leftMotor] = 0;                   // ...the left motor is stopped with a power level of 0.
    }
  }
}


So the important things to remember are that you have to include the joystickDriver.c, call the function getJoystickValues(joystick) every loop and use the slightly modified joystick variables.
Code:
joystick.joy1_x1
joystick.joy1_y1
joystick.joy1_x2
joystick.joy1_y2


I hope this helps :)

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