Answered: Potentiometer code question (ROBOTC)

So our test potentiometer code is set to run a motor when a button is pressed and the sensor is less then a set value. When we push the button though, nothing happens. Code is written as follows:

#pragma config(Sensor, in1,    potentiometer1,                 sensorPotentiometer)
#pragma config(Motor,  port6,           motor1,        tmotorNormal, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
  while(true)
  {
    if(vexRT[Btn5U] == 1)
    {
      if(SensorValue[potentiometer1] < 4000)
      {
        motor[motor1] = 31;
      }
      else
      {
        motor[motor1] = 0;
      }
    }
    if (vexRT[Btn5D] == 1)
    {
    if(SensorValue[potentiometer1] > 10)
    {
      motor[motor1] = -31;
    }
    else
    {
      motor[motor1] = 0;
    }
  }
}
}

First, verify you are using a valid download method. I successfully used your program with Robot / VEX Cortex Download Method / Download For Competition (VEXnet). For details on the download methods, please contact RobotC.

Make sure the CORTEX is talking to the Joystick. The VEXnet light will be solid green when tethered or flashing green if communicating over VEXnet. You should have a blinking green Robot light indicating the CORTEX is turned on.

Using the Program Debug window is helpful to know where your program is going. You can single step to see the different code branches. The 276-2186 Programming Hardware Kit is helpful. You can assign the button pushes and potentiometer values to global variables for viewing. For other debugging help, contact RobotC.