So I’m in a bit of a dilemma again. I think I know what I’m doing but nothing is working so I would assume not. I don’t know if it’s interfering parameters with the potentiometer or what. Here’s the code:
#pragma config(Sensor, in2, PL, sensorPotentiometer)
#pragma config(Motor, port4, LL, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port5, RL, tmotorVex393_MC29, openLoop, reversed)
#include "JoystickDriver.c"
int joystickvalue = joystick.joy1_y2;
while(true)
{
if(((joystickvalue<0) && (SensorValue[PL]>=1050)) || ((joystickvalue>0) && (SensorValue[PL]<=250)))//if it extends further than the lowest or highest position on the potentiometer. (If the joystick pointed up but it's already higher than I want it to be or if the joystick is pointed down when it's already as low as I want it to be.)//
{
motor[LL] = 0;
motor[RL] = 0;
}
else if(((SensorValue[PL]<1050) && (joystickvalue>0)) || ((SensorValue[PL]>250) && (joystickvalue<0)))//If it's in the correct parameters
{
motor[LL] = joystickvalue;
motor[RL] = joystickvalue;
}
}
So you set joystickvalue one time at the very beginning and never again? Presumably JoystickDriver.c reads the joystick. I’m assuming the pretend loop will actually repeat so the program won’t just end. But you never check for a new joystickvalue in your loop.
Also, it looks like you’re running C++. At some point have you created joystick as an object, or it just a class of objects with no actual object being created?
Also, not being able to see inside JoystickDriver.c, I have to ask if you have set a deadband or not since you’re checking for zeros but the controller won’t necessarily provide zeros when not used.
Ok so I set it up in an actual loop, joystickvalue is at a set integer and it should equal the right joystick on the controller from what I would assume be the “JoystickDriver.c” should I set something like a threshold so it would be a little more accurate and not as finicky?