// Slave code #include Servo myServo; int state = 20; void setup() { myServo.attach(9); Serial.begin(38400); // Default communication rate of the Bluetooth module } void loop() { if(Serial.available() > 0){ // Checks whether data is comming from the serial port state = Serial.read(); // Reads the data from the serial port } // Controlling the servo motor myServo.write(state); delay(10); }