Particle Photon and IFTTT - Need Programming Assistance!

Hello -

I’m new to programming but learning as I go on. The microprocessor I’m using is a Particle Photon which is written in C/C++. One issue I’m having is with a garage door project I’m working on. Would appreciate some insight on my coding (it has need for improvement):

As of now, the garage can be operated via If This Then That (IFTTT) by executing the “recipe” I loaded. These are the two options I’m missing at this point:

(1) The option for IFTTT to “read” the magnetic sensor (Reed Switch), giving me the option to see what status (position) the garage door is (Open or Closed).

(2) The option for IFTTT to determine my location by using the iOS location. Ideally, I want the garage to open or close when I am arriving or leaving for the day - without pressing any buttons.

Here is the current code I have loaded. If there’s something not needed that’s in here, please let me know. Additionally, anything you se that I should have in here to accomplish the two items above would be helpful and appreciated!!

int interval = 1000;
int state = 1;
int oldState;
int ts = Time.now();

int IN1 = D1; // variable for IN1 on relay
int IN2 = D2; // variable for IN2 on relay
int reed = D5; // variable for reed switch
int led = D7;
int doorstatus = digitalRead(reed); //variable for door status

String statusCheck(){
    int status = digitalRead(reed);
    return digitalRead(reed) ? "CLOSED" : "OPEN";
    
}

void setup() {
    // Time.zone(-5);
    Spark.function("relay TEST", relayPulse); 
    Spark.function("open TEST", openDoor);

    pinMode(reed, INPUT_PULLDOWN);
    pinMode(led, OUTPUT);
    pinMode(IN1, OUTPUT);
    pinMode(IN2, OUTPUT);
    
    digitalWrite(IN1, LOW);
    digitalWrite(IN2, LOW);
    
    Spark.variable("state", state);
    Spark.variable("ts", ts);
    // startup status
    Spark.publish("door_status", statusCheck());
    Serial.begin(9600);

}

void loop() {

	oldState = digitalRead(reed); //Check the current state
	
	if (doorstatus != oldState){ //Compare current state to status.
		doorstatus = oldState; //Make oldState the new status
		Spark.publish("door_status", statusCheck());
		state = doorstatus;
		ts = Time.now();
		
	}
    
   delay(interval); //Delay Interval millisecond, as to not to overload the server.

}
// for loacation based IFTTT
int openDoor(String command){
    if (statusCheck() == "CLOSED"){ 
    relayPulse(command);
    return 1;
    }
    return 0;
};

int relayPulse(String command){
    Spark.publish("button pushed by ", command);
    digitalWrite(IN1, HIGH);
    delay(2000);
    digitalWrite(IN1, LOW);
    return 1;
};

Particle Photon? Huh?

MarkT:
Particle Photon? Huh?

Correct, are you familiar with it? I was hoping that since it ran on the same code, it would be a good forum to ask.

I was hoping that since it ran on the same code, it would be a good forum to ask.

Did you compile that code using the Arduino IDE? If not, that comment about “the same code” is nonsense. Just because it is programmed in C++ does not mean that this is the right forum.

Wow! Way to NOT answer or provide a response with substance :slight_smile:

Actually, your response was nonsense......not to mention utterly pointless at the same time (not often that happens).

Sadly, Paul gets nothing today.