
Macro functions and Motor precision/timing
Hello everyone!
I would like to be able to create a code that allows my robot to perform multiple actions with the click of a single button. Along with that, i would like for my motors to be able to turn a specified amount during the command. I originally started with something along the lines of this:
but to my surprise when i pressed the button, the length of the spin was actually determined by the time I held down the button and was extremely inconsistant. If i pressed like normal the motor would spin for x long, but if i pressed it unrealisticly fast it would spin for x-y long...
I figured this was because the computer was executing the commands faster than i could move my finger, so the code was actually executing more than once. To combat this, i added:
I hoped, in vain, that the extra wait1msec would give the user time to press and release the button, but the effect was actually far more different... Instead the motor continued to spin the extra 100 milliseconds...
Is there a way to make the motor spin a certain amount in a given time with the use of a single button? Or better yet, do the HiTechnic DC motors have encoders i can use to specify the degree of the turn? (I know the servos do, but one of my senior club members told me the DC motors did not)
Thank you in advance!