Page 1 of 1

Author:  zdoll11 [ Thu Jul 08, 2010 3:55 pm ]
Post subject:  Potentiometers

It seems there is little info in the sample programs as to how to retrieve data from a potentiometer, please help with any available info. Thanks.

Author:  bfeher [ Wed Jul 14, 2010 9:40 am ]
Post subject:  Re: Potentiometers


You can read the values of the Potentiometer Sensor just like any other sensor, by using the

For the VEX2.0 Cortex, the Potentiometer returns values from 0 to 4095, however due to the mechanical design there may be physical stops, limiting the actual reading from 5 to 4090 or so. This seems to range from sensor to sensor so just plug yours in and see what you get.

Below is a program that reads the values of a Potentiometer Sensor attached to Analog Sensor Port 6, and displays the values to the VEX LCD. If you don't have an LCD, you can just as easily (and more accurately) see the values in the ROBOTC Debugger under the "Sensors" tab (Robot > Debug Windows > Sensors)
#pragma config(ProgramType, StandaloneWiFi)
#pragma config(UART_Usage, UART2, VEX_2x16_LCD)
#pragma config(Sensor, in6,    potentioSensor,      sensorPotentiometer)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
    clearLCDLine(1);                                      // Clear LCD Bottom Line
    displayLCDPos(1,0);                                   // Set the cursor to bottom line, first position
    displayNextLCDString("Potentio: ");                   // Print "Potentio: " starting at the cursor position
    displayNextLCDNumber(SensorValue(potentioSensor));    // Display the reading of the Potentiometer to current cursor position
    wait1Msec(150);                                       // Wait 150 milliseconds to help the LCD refresh nicely

potentiometerTest.c [858 Bytes]
Downloaded 1116 times

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group