// Moves a servo and toggles an LED #include Servo myservo; const int servoPin = 9; const int ledPin = 13; // the pin that the LED is attached to int incomingByte; void setup() { Serial.begin(9600); pinMode(ledPin, OUTPUT); myservo.attach(servoPin); } void loop() { if (Serial.available() > 0) { incomingByte = Serial.read(); if( incomingByte == 'H' ) { digitalWrite(ledPin, HIGH); Serial.println("On"); } else if (incomingByte == 'L') { digitalWrite(ledPin, LOW); Serial.println("Off"); } else if (incomingByte >= '0' && incomingByte <= '9') { int pos = (incomingByte -'0') * 20; myservo.write( pos); Serial.println(pos, DEC); } } }