View Single Post
  #4   Spotlight this post!  
Unread 06-02-2011, 23:16
kinganu123 kinganu123 is offline
Registered User
FRC #1747
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Piscataway, NJ
Posts: 243
kinganu123 is on a distinguished road
Re: Can you use a potentiometer to control motor position?

this is psuedocode
this is assuming that the pot gives a value from 0-360 (sorry, but I've nvr used a potentiometer befor, so bear with me)
Code:
if(desiredAngle==pot.getAngle)
//stops motor from moving arm if you're at the angle you need to be at
jag.set(0);
else
/*moves jag forward or backward to get you at the desired angle
does it so fast if far away and slow if close
it will ultimately slow to a stop after it start moving*/
jag.set((desiredAngle-180)/360);
__________________

Last edited by kinganu123 : 06-02-2011 at 23:41.
Reply With Quote