void setup(){ pinMode(5,OUTPUT); //set the pin to output Serial.begin(9600); //open the serial to print Serial.print(“Ready”); //write a message } void loop(){ int val = Serial.read(); //read the serial to see if(val>’0’ && val <= ‘9’){ //which key was pressed val = val - ‘0’; //convert the character to an integer val = val * (180/9); //9 divisions of 180 degrees Serial.print(“moving servo to “); Serial.print(val,DEC); Serial.println(); for(int a=0; a<50; a++){ int pulseWidth = (val*11)+500; // See the formula above digitalWrite(5,HIGH); delayMicroseconds(pulseWidth); digitalWrite(5,LOW); delay(20); } } }