potentiometer

how do you program a potentiometer sensor to stop at a certain point turing autonomous on the CORTEX V4?

A potentiometer will return a value directly corresponding to the position (measured by the resistance)
Just make a conditional to stop a motor when the value changes to the threshold

First, find the value at which you want the part to stop at. You kind find the resistance value by using the debugger (For RobotC, I don’t know what to use for EasyC).

For EasyC, it would be something like:
Retrieve Potentiometer Value -> While Potentiometer is [not equal to, less than, greater than…] your wanted value{ Your wanted function} -> Stop motors
(Excuse my horrible Pseudo code-)

For RobotC, it would be something like:


/* THIS IS JUST A COMMENT.
0000 = your resistance value (potentiometer value)
5555 =  motor power*/

while(SensorValue[POTENTIOMETER] < 0000) // while the potentiometer is less than said value..{
motor[ARM] = 5555; // run motor at 5555 power
}
motor[ARM] = 0; // stop motor

im trying to make a program for the potentiometer as well. me and the other Devin are going to try to get it to work this week

Are you using EasyC or RobotC? If I have time, I’ll try make a sample program for you. Although I only have EasyC for the PIC microprocessor. Actual syntax may differ.

If you guys get it to work, can you let me know how, because I’ve been fiddling around with the optical shaft and I still don’t have a clue. I think I might be going in the right direction, but if no one responses to my other posts, I won’t know how much progress I’m making.

No one is answering my question… So I’ll assume EasyC. As soon as I come home from school, I’ll work on a program for you.

With the time spent at robotics, that’s 11 hours from now.

yes we use EasyC. a sample program would be greatly appreciated. and John if we get it to work we will give you a call or you can come over and copy the program. and I have a couple surprises for robotics when we get back from break :wink:

Do you guys want the actual picture? For now, I shall type the code-

#include "Main.h"

void main ( void )
{
  int armAboveLowGoal = 888; // this can be any value, pertaining to your function
  int potentiometerValue;

  potentiometerValue = GetAnalogInput ( 1 );
  while ( potentiometerValue < armAboveLowGoal )
  {
    SetMotor ( 1 , 255 );
    SetMotor ( 2 , 0 );
  }
  SetMotor ( 1 , 127);
  SetMotor( 2 , 255 );

This is the basic format. If you want to apply stops via programming, I show you as well… The two motor statements after the while statement may not be necessary, but it was needed for our PICs.