Ibrahim FadhelNazar Alsadeq
Published

Garage Door Controller

Have you ever been locked out the house? Do you wish to control your garage door with your phone? You came to the right place. MEGR3171.

IntermediateShowcase (no instructions)8 hours1,088
Garage Door Controller

Things used in this project

Hardware components

Photon
Particle Photon
×2
Relay (generic)
×2
magnetic sensor
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1
Velcro
×1

Software apps and online services

Maker service
IFTTT Maker service
ThingSpeak API
ThingSpeak API

Story

Read more

Schematics

Garage Door Controller

Garage Light

Garage Door Controller

Garage Light

Garage Operation

Garage Operation Data

Code

Garage Door Controller

C/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 Light

C/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

Ibrahim Fadhel

Ibrahim Fadhel

1 project • 0 followers
Nazar Alsadeq

Nazar Alsadeq

1 project • 0 followers

Comments