Simple Motor rotation control problem

I have an arduino board all hooked up to a servo motor that is going to control a mechanical claw. I would like to write and code where I can enter something like '1' on my keyboard and have the motor rotate 180 degrees. then press '0' and have it rotate from 180 degrees backwards to zero. Essentially opening and closing the mechanical claw. If this is at all possible..

I found the code named 'sweep' on the arduino website and it rotates my motor correctly, I would just like to be able to control when the motor rotates using my keyboard.

I am very new to programming and have been trying to learn how to do this online to no avail.

Any help writing this code would be greatly appreciated!
Last edited on
What you need to know is the speed of the rotation. I.e. What's the degree per second.

If the speed is 10 degree per second you need to let the motor run for 18 seconds
Topic archived. No new replies allowed.