#include Servo myservo; // create servo object to control a servo // twelve servo objects can be created on most boards int pos = 0; // variable to store the servo position void setup() { myservo.attach(9); // attaches the servo on pin 9 to the servo object Serial.begin(9600); //start serial communication @9600 bps } void loop(){ if(Serial.available()){ //id data is available to read char val = Serial.read(); if(val == 'C'){ //if C received myservo.write(170); ; //servo motor moves to 170 degree position } if(val == 'O'){ //if O received myservo.write(0); ; //servo motor moves to 0 degree position } if(val == 'F'){ //if F received myservo.write(170); //servo motor moves to 170 degree position delay(500); //servo motor hold position for 0.5 sec myservo.write(0); //servo motor moves to 0 degree position } } }