Motor rotation control

I have my 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!

haydenmay10:
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.

If it's the keyboard attached to your computer, open the IDE and the serial monitor.
You can then use the computer's keyboard to send keystrokes to your Arduino.
Look up, in the reference page of this site, 'serial in' to see how to read the input keystrokes.