Things used in this project

Hardware components:
Photon new
Particle Photon
×2
Relay (generic)
×2
magnetic sensor
×1
11026 02
Jumper wires (generic)
×1
12002 04
Breadboard (generic)
×1
Velcro
×1
Software apps and online services:
Q8wtlimqnp04fzhtr9v5
IFTTT Maker service
Hackster
ThingSpeak API

Schematics

Garage Door Controller
Whatsapp image 2017 11 21 at 10 47 46 pm (1) ahpsaawjvi
Garage Light
Whatsapp image 2017 11 21 at 10 47 46 pm (3) r716xmudof
Garage Door Controller
Whatsapp image 2017 11 21 at 10 47 46 pm (2) yjqwm4ilev
Garage Light
Whatsapp image 2017 11 21 at 10 47 46 pm (4) cxqdygiis0
Garage Operation
Garage Operation Data
Screen shot 2017 11 24 at 11 05 21 pm bwfrgqz0zi

Code

Garage Door ControllerC/C++
This code is used via a photon particle. copy and paste this code to your photon on https://build.particle.io/build/new with modifications if applicable, then you will be able to control your garage using your smart phone.
// This part of the code defines the pins that are being used. D0 is for the garage output and A0 is for the garage analog pin which will be serving as out input. The initial value will be set at 10. This is dependant on the sensor. 

int Door = D0;
int aPin = A1; 
int Sensor = 10;

// Below is setting up which pin is what and what the functions are. In this case the door movement will serve as our ultimate output and the analong pin as our input where it gets the directions to trigger the relay. 
void setup(){
  Serial.begin( 10400 );
  pinMode(Door, OUTPUT);     
  pinMode(aPin, INPUT);

// This is where the whole function is connected to an If this then that program or IFTTT. This will send an email to let know of the status of the garage whether is open or closed based on the functions below. 

Particle.function("IbrahimGarage",WelcomeHome);
}

// This loop is to control the open and close based on the sensor values. 

void loop(){}
 

 int WelcomeHome(String command){
  Sensor = analogRead(aPin);

  if (command=="on" && Sensor<6000) {
         
        digitalWrite(Door,HIGH);
        delay(100);
        digitalWrite(Door,LOW);
        Particle.publish("The_Garage_is_Now_Open","OPENED");
        return 1;
  }
   
    else if  (command=="off" && Sensor>6000) {

        digitalWrite(Door,HIGH);
        delay(100);
        digitalWrite(Door,LOW);
        Particle.publish("The_Garage_is_Now_Closed","CLOSED");
        return 0;
  }
  
  else {
      return -1;
  }
  }
Garage LightC/C++
int Lamp = D0; 
void setup() {
     pinMode(light,OUTPUT); 
     Particle.subscribe("The_Garage_is_Now_Opened",Light);
}
void loop (){}
void Light(const char *event, const char *data){
    { 
        delay(5000);
         digitalWrite(Lamp,HIGH);
      delay(15000);
      digitalWrite(Lamp,LOW);
      }
 }

Credits

Photo
Ibrahim Fadhel
1 project • 0 followers
Contact
Screen shot 2017 06 09 at 1 41 45 am vohw0ssegv
Nazar Alsadeq
1 project • 0 followers
Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Add projectSign up / Login