#define ledPin 13 int state = 0; void setup() { pinMode(ledPin, OUTPUT); digitalWrite(ledPin, LOW); Serial.begin(9600); } void loop() { if(Serial.available() > 0){ // Listening for BT communication state = Serial.read(); // Reads the data from the serial port } if (state == '0') { digitalWrite(ledPin, LOW); // Turn LED Off state = 0; } else if (state == '1') { digitalWrite(ledPin, HIGH); // Turn LED On state = 0; } delay (50); }