//Based on roboremo website, modified buy Zarkani // Garage door opener using arduino and roboremo app, check www.roboremo.com int led1 = 13; int led2 = 12; int led3 = 11; int led4 = 10; int doorState; char cmd[100]; int cmdIndex; void exeCmd() { if(strcmp(cmd, "led1 0")==0) digitalWrite(led1, LOW); if(strcmp(cmd, "led1 1")==0) digitalWrite(led1, HIGH); if(strcmp(cmd, "led2 0")==0) digitalWrite(led2, LOW); if(strcmp(cmd, "led2 1")==0) digitalWrite(led2, HIGH); if(strcmp(cmd, "led4 0")==0) digitalWrite(led4, LOW); if(strcmp(cmd, "led4 1")==0) digitalWrite(led4, HIGH); } void setup() { Serial.begin(115200);// change baud rate according to your bluetooth delay(500); // wait for bluetooth module to start pinMode(led1, OUTPUT);// the pin that turns the relay on and off which opens and closes the door pinMode(led2, OUTPUT); // spare pinMode(led3, INPUT_PULLUP);// gives feedback from the reed relay, is the door open or closed? pinMode(led4, OUTPUT);// spare digitalWrite(led1, LOW); digitalWrite(led2, LOW); digitalWrite(led4, LOW); cmdIndex = 0; } void loop() { int doorState = digitalRead(led3); //check door, open/closed if (doorState==1) Serial.print("led3 1\n");// door is open if (doorState==0) Serial.print("led3 0\n");// door is closed if(Serial.available()) { char c = (char)Serial.read(); if(c=='\n') { cmd[cmdIndex] = 0; Serial.println(cmd[cmdIndex]); exeCmd(); // execute the command cmdIndex = 0; // reset the cmdIndex } else { cmd[cmdIndex] = c; if(cmdIndex<99) cmdIndex++; } } }