#define ledPin PD6 int state = 0; void setup() { pinMode(ledPin, OUTPUT); digitalWrite(ledPin, LOW); Serial.begin(9600); // Default communication rate of the Bluetooth module } void loop() { if(Serial.available() > 0){ // if data available at serial port state = Serial.read(); // assign incoming data to variable state Serial.write(state); } // Controlling the LED if (state == '1') { digitalWrite(ledPin, HIGH); // LED On state = 1; } else if (state == '0') { digitalWrite(ledPin, LOW); // LED Off state = 0; } }