#include //Software Serial Port #define DEBUG_ENABLED 1 SoftwareSerial blueToothSerial(1,2); unsigned int state = 0; void setup() { pinMode(1, INPUT); pinMode(2, OUTPUT); pinMode(0, OUTPUT); blueToothSerial.begin(9600); delay(2000); blueToothSerial.println("bluetooth connected!\n"); delay(2000); // This delay is required. blueToothSerial.flush(); } void loop() { if(blueToothSerial.available() > 0){ state = blueToothSerial.read(); if(state == 1) { digitalWrite(0, HIGH); blueToothSerial.println("ON"); } else if(state ==0) { digitalWrite(0, LOW); blueToothSerial.println("OFF"); } } }