FIRST Tech Challenge Discussions

Showing results for 
Search instead for 
Did you mean: 

Help! How to program a motor to turn in certain degrees?

i. we are trying to program a 6th moter to turn only 30 degrees, then turn back to its original position. We have never used a button on the joystick to do this. Can anyone give us the full code for this?

0 Kudos
Message 1 of 3

Can you explain a bit more about what you are trying to do?  I presume you mean a DC motor and you are looking to turn it X degrees (90, 180) etc.  If so, why are you using a DC motor instead of a servo?  DC motors are not really intended to reliably move a certian numebr of degrees. 

0 Kudos
Message 2 of 3

If you are using a DC Motor, you could get some pretty good results using an attached encoder.  There's an encoder tutorial here:

Otherwise, I agree with Eddie that a servo would work better in this case as servos are designed to move to precise positions.  A stepper motor might serve well too.  You could figure out how many steps it took to move 30 degrees and hard-code that number.

-Jim B
Applications Engineer, National Instruments
0 Kudos
Message 3 of 3