Can't get V5 to recognize potentiometer

Cannot get the V5 to register the potentiometer. Checked the Brain’s Devices button & we tested 4 different ports then 5 differents pots but when the axle in the pot is moved nothing happens. Made print commands for the pot.value to the Brain & Controller but is registering no change so our DR4B keeps going up & not stopping. Initially, kids typed robot config like this as this is how it imported from VCS last year into VEX Code Preview.
vex::pot ArmPot( Brain.ThreeWirePort.A);Preformatted text`

Was told in VEX Code Preview it should be this:
vex::pot ArmPot = vex::pot(Brain.ThreeWirePort.A);
Still didn’t register any changes. Tried a 4th new port D, it worked so went back to port B & C to see if it would now work. Didn’t so went back to port D but now it doesn’t work.

We use jPearman’s button template so rewrote it into a simple short auto to ensure nothing else was interfering with the code. Still doesn’t work. What are we doing wrong? Looks like all of our 3 wire ports are not working or our code is totally messed up. Please help… jokai

    #include "vex.h"

using namespace vex;

vex::competition Competition;


void pre_auton( void ) {
}

void autonomous( void ) {
    Controller1.Screen.print("hello");
    vex::task::sleep(500);
    while(1){
      Brain.Screen.printAt(125,60,"%f",ArmPot.value(rotationUnits::raw));
      Controller1.Screen.print("%f",ArmPot.value(rotationUnits::raw));
      task::sleep(500);
    }
}

void usercontrol( void ) {
  while (1) {
    vex::task::sleep(20); //Sleep the task for a short amount of time to prevent wasted resources. 
  }
}

int main() {
    Competition.autonomous( autonomous );
    Competition.drivercontrol( usercontrol );
    
    pre_auton();
                              
    while(1) {
      vex::task::sleep(100);//Sleep the task for a short amount of time to prevent wasted resources.
    }    
       
}

PS Last year, we couldn’t get the gyro to register either in port F

`

Joan
I just tried the code above, works here with no issues.

can you verify if the pot is working when you use the V5 dashboard ?
3wire
Make sure the connector is pushed all the way in, the 3wire connector should be flush with the housing.

1 Like

Thank you jpearman! Yes I had been checking it against the dashboard & it wasn’t registering. Had kept telling the kids to make sure it was pushed all the way into the brain & they insisted it was. Should have checked myself - it wasn’t all the way in. Sorry & Thanks. Anyway, as far as declaring the sensors & controller, what is the correct way in VEX Code Preview… see my post above. Thanks :slight_smile: joan
PS owe you more MacNuts!

you were declaring the potentiometer correctly. Here is you code with the controller and pot added in the way I would usually do it.

Code
/*----------------------------------------------------------------------------*/
/*                                                                            */
/*    Module:       main.cpp                                                  */
/*    Author:       james                                                     */
/*    Created:      Mon Jun 24 2019                                           */
/*    Description:  V5 project                                                */
/*                                                                            */
/*----------------------------------------------------------------------------*/
#include "vex.h"

using namespace vex;

// A global instance of vex::brain used for printing to the V5 brain screen
vex::brain       Brain;

// define your global instances of motors and other devices here
vex::controller  Controller1;
vex::competition Competition;
vex::pot         ArmPot(Brain.ThreeWirePort.A);

void pre_auton( void ) {
}

void autonomous( void ) {
    Controller1.Screen.print("hello");
    vex::task::sleep(500);
    while(1){
      Brain.Screen.printAt(125,60,"%.2f",ArmPot.value(rotationUnits::raw));
      Controller1.Screen.print("%.2f",ArmPot.value(rotationUnits::raw));
      task::sleep(500);
    }
}

void usercontrol( void ) {
  while (1) {
    vex::task::sleep(20); //Sleep the task for a short amount of time to prevent wasted resources. 
  }
}

int main() {
    Competition.autonomous( autonomous );
    Competition.drivercontrol( usercontrol );
    
    pre_auton();
                              
    while(1) {
      vex::task::sleep(100);//Sleep the task for a short amount of time to prevent wasted resources.
    }    
}
1 Like