I would like to take the current location of the servo, and change the position, then be able to do this again, so that I can hit one key to make it move forward, and one key to make it move backward. (I want to have it move in degrees, not over a certain period of time like the code zoomkat gave me.)
So, you want to increment/decrement a value, based on the character read from the serial port. You can do that.
int pos = 90;
// set serial option and attach the servo
if(Serial.available() > 0)
char aChar = Serial.read();
if(aChar == 'p')
val += 5;
else if(aChar == 'm')
val -= 5;
I already tried to declare an int and and have serial read the current angle of the servo. Then add one to the angle when a certain String was read in the Serial Monitor. I hope that clears up what that means. (I am still getting used to the syntax sorry)
And the code looks like?