How do i program the potentiometer on easyc?

I need help programming the potentiometer on easyc it’s my first year and I need help.

You’ll have to be more specific about what part of the robot the POT is connected to, and what you want to use it for.

I want to put it on my mini bar which holds my rollers for the cones

It’s one motor that moves the rollers up and down that’s where the potentiometer is but I don’t know how to program it.

Do you know how to program it?

In easyC, whenever you use a sensor, you must first read the sensor value into a variable, something like the following (sorry, I’m not at a computer with easyC, so I can’t get the exact syntax):


POTvalue = getSensorAnalog(myPotentiometer)

Then to do something with this information, like in a while loop, you’d do like so:

//get starting sensor value
POTvalue = getSensorAnalog(myPotentiometer)

while POTvalue < 900 {
   // do something, like have motors turn on

   // update sensor value for next go-around
   POTvalue = getSensorAnalog(myPotentiometer)
}
// have the motors turn off (usually)

In easyC, you can’t directly check the value of the sensor in the while comparison statement, as is done in RobotC. So you first read the value before the while loop so that you have something to start with, and then once you enter the while loop, you must update the sensor value each time through; it will not do that itself. So that’s why you’ll want to have the last line of your while loop like it’s written above, so that you get a new reading right before it loops back to the comparison statement.

In general, this is the format you’d use for any sensor data in easyC: (a) read it into a variable, (b) check that value against something, © make the robot do something based on this value, (d) check the value again, (e) repeat and fade… You’d use “getSensorAnalog” or “getSensorDigital” as appropriate.

In the motor & sensor setup window, it will help if you give each motor and sensor a name, so that when you use the getSensorAnalog function block, for example, you’ll see the sensor name from the dropdown list; you don’t have to remember which port anything was plugged into.

Does this help?