Close

Code For Our Project and Materials

A project log for Home Automation System

In this project we automated household appliances and we used a Arduino, Bluetooth Module, wires and sensors

shaherayar-khanShaherayar Khan 09/15/2018 at 05:580 Comments

The Code is:

#include <dht.h>

#define dht_apin A0

dht DHT;

#include <SoftwareSerial.h>

SoftwareSerial BT(10,11); // RX, TX

int vib_pin=2;

int led_pin=13;

int led = 8;                     

int val = 0;                               

void setup() {

 Serial.begin(9600);

 BT.begin(9600);

 pinMode(vib_pin,INPUT);

 pinMode(led_pin,OUTPUT);

 pinMode(7,INPUT);

 pinMode(led, OUTPUT);   

}

void loop() {

 int s;

 int inByte = 0;

 int motion = digitalRead(7);

  val = digitalRead(motion);   

 if (val == HIGH) {           

   digitalWrite(led, HIGH);  

   delay(50);                

 }

 else {

     digitalWrite(led, LOW);

     delay(50);               

   Serial.println(val);

 }

  DHT.read11(dht_apin);

   Serial.print("Current humidity = ");

   Serial.print(DHT.humidity);

   Serial.print("%  ");

   Serial.print("temperature = ");

   Serial.print(DHT.temperature);

   Serial.println("C  ");

   delay(5000);         

 BT.write(motion);

 delay(500);

 if (BT.available()){

   inByte = BT.read();

   if(inByte == 'S'){

     while(!BT.available()){}

     digitalWrite(13,HIGH);

   }

    if(inByte == 'X'){

     while(!BT.available()){}

     digitalWrite(13,LOW);

   }

    }

    Serial.println(motion);

}

The Materials are:

  1. Magnetic Lock 
  2. Two relays 
  3. Bluetooth module
  4. Breadboard 
  5. PIR Sensor 
  6. DHT Sensor 
  7. Arduino UNO
  8. LED
  9. Wires 

Code For Android App


Thanks for Viewing this log.

Discussions