Skip to main content
deleted 1 character in body
Source Link

Under normal operation, the value of a joystick's ADC range on my board is from 0 to 1023 (10-bits). However, my graph for either axis is not continuous. Rather, there is more than one min and maximum for both axis. I am running this thread on a MSP432P401R however the code isn't any different than an Arduino.

int jumpFlag;
int backwardsFlag;
int forwardsFlag;
int selPin = P5_1; //Select digital pin location
int xOutPin = A14;
int yOutPin = A13;

void setupPlayerActions() {
  pinMode(selPin, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(selPin),jumpISR,RISING);
  //pinMode(xOutPin, ); //Analog X pin setup
  //pinMode(xOutPin, ); //Analog Y pin setup
}

void jumpISR() {
  Serial.println("Jump Detected!");
  jumpFlag = 1;
}


void loopPlayerActions() {
  int x_adc_val, y_adc_val; 
  int leftThreshold=50,rightThreshold=1600;rightThreshold=900;
  float x_volt, y_volt;
  x_adc_val = analogRead(xOutPin);
  y_adc_val = analogRead(yOutPin);
  x_volt = ( ( x_adc_val ));  /*Convert digital value to voltage */
  y_volt = ( ( y_adc_val));  /*Convert digital value to voltage */
  if (x_volt < leftThreshold){
    Serial.println("Move Backwards");
  }
  else if (x_volt < rightThreshold){
    Serial.println("Move Forwards");
  }
  Serial.println("X_Voltage = ");
  Serial.print(x_volt);
  Serial.print("\t");
  //Serial.print("Y_Voltage = ");
  //Serial.println(y_volt);
  delay(100);

  //delay(250);
}

The graph goes to zero for all positive x and y integers however it briefly reaches a maximum past a small value on the -x and -y axis then sinks to about ~420. What could be causing this?

Under normal operation, the value of a joystick's ADC range on my board is from 0 to 1023 (10-bits). However, my graph for either axis is not continuous. Rather, there is more than one min and maximum for both axis. I am running this thread on a MSP432P401R however the code isn't any different than an Arduino.

int jumpFlag;
int backwardsFlag;
int forwardsFlag;
int selPin = P5_1; //Select digital pin location
int xOutPin = A14;
int yOutPin = A13;

void setupPlayerActions() {
  pinMode(selPin, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(selPin),jumpISR,RISING);
  //pinMode(xOutPin, ); //Analog X pin setup
  //pinMode(xOutPin, ); //Analog Y pin setup
}

void jumpISR() {
  Serial.println("Jump Detected!");
  jumpFlag = 1;
}


void loopPlayerActions() {
  int x_adc_val, y_adc_val; 
  int leftThreshold=50,rightThreshold=1600;
  float x_volt, y_volt;
  x_adc_val = analogRead(xOutPin);
  y_adc_val = analogRead(yOutPin);
  x_volt = ( ( x_adc_val ));  /*Convert digital value to voltage */
  y_volt = ( ( y_adc_val));  /*Convert digital value to voltage */
  if (x_volt < leftThreshold){
    Serial.println("Move Backwards");
  }
  else if (x_volt < rightThreshold){
    Serial.println("Move Forwards");
  }
  Serial.println("X_Voltage = ");
  Serial.print(x_volt);
  Serial.print("\t");
  //Serial.print("Y_Voltage = ");
  //Serial.println(y_volt);
  delay(100);

  //delay(250);
}

The graph goes to zero for all positive x and y integers however it briefly reaches a maximum past a small value on the -x and -y axis then sinks to about ~420. What could be causing this?

Under normal operation, the value of a joystick's ADC range on my board is from 0 to 1023 (10-bits). However, my graph for either axis is not continuous. Rather, there is more than one min and maximum for both axis. I am running this thread on a MSP432P401R however the code isn't any different than an Arduino.

int jumpFlag;
int backwardsFlag;
int forwardsFlag;
int selPin = P5_1; //Select digital pin location
int xOutPin = A14;
int yOutPin = A13;

void setupPlayerActions() {
  pinMode(selPin, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(selPin),jumpISR,RISING);
  //pinMode(xOutPin, ); //Analog X pin setup
  //pinMode(xOutPin, ); //Analog Y pin setup
}

void jumpISR() {
  Serial.println("Jump Detected!");
  jumpFlag = 1;
}


void loopPlayerActions() {
  int x_adc_val, y_adc_val; 
  int leftThreshold=50,rightThreshold=900;
  float x_volt, y_volt;
  x_adc_val = analogRead(xOutPin);
  y_adc_val = analogRead(yOutPin);
  x_volt = ( ( x_adc_val ));  /*Convert digital value to voltage */
  y_volt = ( ( y_adc_val));  /*Convert digital value to voltage */
  if (x_volt < leftThreshold){
    Serial.println("Move Backwards");
  }
  else if (x_volt < rightThreshold){
    Serial.println("Move Forwards");
  }
  Serial.println("X_Voltage = ");
  Serial.print(x_volt);
  Serial.print("\t");
  //Serial.print("Y_Voltage = ");
  //Serial.println(y_volt);
  delay(100);

  //delay(250);
}

The graph goes to zero for all positive x and y integers however it briefly reaches a maximum past a small value on the -x and -y axis then sinks to about ~420. What could be causing this?

Source Link

Joystick reading erroneous values

Under normal operation, the value of a joystick's ADC range on my board is from 0 to 1023 (10-bits). However, my graph for either axis is not continuous. Rather, there is more than one min and maximum for both axis. I am running this thread on a MSP432P401R however the code isn't any different than an Arduino.

int jumpFlag;
int backwardsFlag;
int forwardsFlag;
int selPin = P5_1; //Select digital pin location
int xOutPin = A14;
int yOutPin = A13;

void setupPlayerActions() {
  pinMode(selPin, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(selPin),jumpISR,RISING);
  //pinMode(xOutPin, ); //Analog X pin setup
  //pinMode(xOutPin, ); //Analog Y pin setup
}

void jumpISR() {
  Serial.println("Jump Detected!");
  jumpFlag = 1;
}


void loopPlayerActions() {
  int x_adc_val, y_adc_val; 
  int leftThreshold=50,rightThreshold=1600;
  float x_volt, y_volt;
  x_adc_val = analogRead(xOutPin);
  y_adc_val = analogRead(yOutPin);
  x_volt = ( ( x_adc_val ));  /*Convert digital value to voltage */
  y_volt = ( ( y_adc_val));  /*Convert digital value to voltage */
  if (x_volt < leftThreshold){
    Serial.println("Move Backwards");
  }
  else if (x_volt < rightThreshold){
    Serial.println("Move Forwards");
  }
  Serial.println("X_Voltage = ");
  Serial.print(x_volt);
  Serial.print("\t");
  //Serial.print("Y_Voltage = ");
  //Serial.println(y_volt);
  delay(100);

  //delay(250);
}

The graph goes to zero for all positive x and y integers however it briefly reaches a maximum past a small value on the -x and -y axis then sinks to about ~420. What could be causing this?