To control motor's rotation...

Hi

I’m trying to control the motor’s rotation with a button
I want the motor to turn certain degrees when a button is pressed

so i built a function called MotorDegree, and used For loop to control the rotation. [pwm01 = MotorDegree(p1_sw_trig)]

But it appears that the motor’s movement (pwm01) doesn’t require the button’s activation (p1_sw_trig). It turns automatically once the robot initiates.

I used If command in the function so that the function runs only if the trigger is pressed (when it’s 1 or above 0)

What is wrong?

Hi,
How about posting your code for the MotorDegree() function. Are you trying to make the motor turn less than 1 shaft revolution? Or are you trying to use the motor to raise an arm by some angular amount? If it is an arm, what are you using for feedback? A potentiometer?

Regards,
ChuckB

Thanks for replying

I found the problem and the thing works now.