Prototype Controlled Home Automation Using Arduino

Prototype Controlled Home Automation Using Arduino © MIT

This project is a prototype of a smart home.

  • 299 views
  • 1 comment
  • 3 respects

Components and supplies

Necessary tools and machines

Apps and online services

About this project

On the light control when the light conditions are bright, the Lamp will turn OFF or turn off. Whereas when the light conditions are dark or not lit, the lights will turn ON or turn on. In the clothesline control when the light conditions are bright, the rain sensor is in high condition and the servo motor is rotating 55 degrees, while when the light conditions are dark, the rain sensor is in a low state and the servo motor is rotating 150 degrees. In the control box there are 3 conditions, namely the first when the Rain Sensor (lower limit) Low and Rain Sensor (upper limit) Low then the water pump will turn on (ON), second when the Rain Sensor (lower limit) High and Rain Sensor (upper limit) Low then the water pump will turn on (ON), third when the Rain Sensor (lower limit) High and Rain Sensor (upper limit) High then the water pump will die (OFF).

Code

dadi.inoArduino
#include <Servo.h>
Servo myservo;
int hujan=8;
int bawah=6;
int atas=7;
int motor=10;
int led2=2;
int led3=3;
int led4=4;
int led5=5;
int ldrjemur=A0;
int ldrlampu=A1;
int nilai, jemur;
int button1=11;
int button2=12;


void setup() {
  Serial.begin(9600);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);
  pinMode(led5, OUTPUT);
  pinMode(motor, OUTPUT);
  pinMode(hujan, INPUT_PULLUP);
  pinMode(atas, INPUT_PULLUP);
  pinMode(bawah, INPUT_PULLUP);
  pinMode(button1, INPUT_PULLUP);
  pinMode(button2, INPUT_PULLUP);
  myservo.attach(9);
}

void manual(){
  if(Serial.available()>0)
  {
    char data = Serial.read();
    if (data == 'a')
    {digitalWrite(led2,HIGH);}
    else if(data == 'b')
    {digitalWrite(led2,LOW);}
    else if(data == 'c')
    {digitalWrite(led3,HIGH);}
    else if(data == 'd')
    {digitalWrite(led3,LOW);}
    else if(data == 'e')
    {digitalWrite(led4,HIGH);}
    else if(data == 'f')
    {digitalWrite(led4,LOW);}
    else if(data == 'g')
    {digitalWrite(led5,HIGH);}
    else if(data == 'h')
    {digitalWrite(led5,LOW);}
    else if(data == 'i')
    {digitalWrite(motor, HIGH);}
    else if(data == 'j')
    {digitalWrite(motor,LOW);}
    else if(data == 'k')
    {myservo.write(55); }
    else if(data == 'l')
    {myservo.write(150); }
  }

}



void lampu(){
  nilai=analogRead(ldrlampu);
  
  if (nilai<500){
    digitalWrite(led2, LOW);
    digitalWrite(led3, LOW);
    digitalWrite(led4, LOW);
    digitalWrite(led5, LOW);
    Serial.print("============LAMPU===========\n");
    Serial.print("Nilai sensor : ");
    Serial.print(nilai);
    Serial.print("\t");
    Serial.print("LAMPU OFF");
    Serial.print("\n");
    Serial.print("============================");
    Serial.print("\n \n");
    delay(300);
  }
  else{
     digitalWrite(led2, HIGH);
     digitalWrite(led3, HIGH);
     digitalWrite(led4, HIGH);
     digitalWrite(led5, HIGH);
     Serial.print("============LAMPU===========\n");
     Serial.print("Nilai sensor : ");
     Serial.print(nilai);
     Serial.print("\t");
     Serial.print("LAMPU ON");
     Serial.print("\n");
     Serial.print("===========================");
     Serial.print("\n \n");
     delay(300);
  }
}

void jemuran(){
  jemur=analogRead(ldrjemur);
  
  if (jemur>500){
    if (digitalRead(hujan)==LOW){
      Serial.print("============JEMURAN===========\n");
      Serial.print("Nilai sensor : ");
      Serial.print(jemur);
      Serial.print("\t");
      Serial.print("Hujan");
      Serial.print("\n");
      Serial.print("=============================");
      Serial.print("\n \n");
      delay(300);
      myservo.write(150); 
      delay(15);  
    }
  }

  else if (jemur<500){
    if (digitalRead(hujan)==HIGH){
      Serial.print("============JEMURAN===========\n");
      Serial.print("Nilai sensor : ");
      Serial.print(jemur);
      Serial.print("\t");
      Serial.println("Tdk Hujan");
      Serial.print("\n");
      Serial.print("=============================");
      Serial.print("\n \n");
      delay(300);
      myservo.write(55); 
      delay(15);  
    }
  }
  
}

void tandon(){
  if(digitalRead(bawah)==LOW){
    if (digitalRead(atas)==LOW){
     digitalWrite(motor, LOW);
    }
  }

  else if(digitalRead(bawah)==HIGH){
    if (digitalRead(atas)==HIGH){
      digitalWrite(motor, HIGH);
    }
    
  }
}
void otomatis(){
  lampu();
  jemuran();
  tandon();
}
void tombol(){
 
  if (digitalRead(button1)==LOW){
  while(1){
    lampu();
    jemuran();
    tandon();
    if (digitalRead(button2)==LOW){
      break;
    }
  }
  }

 if (digitalRead(button2)==LOW){
    while(1){
      manual();
      if (digitalRead(button1)==LOW){
      break;
    }
    }
 } 
}

void loop() {
  tombol();
}

Schematics

alhamdulilllah_dadi_mYqqOLyPV5.png
Alhamdulilllah dadi myqqolypv5

Comments

Similar projects you might like

Voice Controlled Home Automation Prototype

Project showcase by Bharath Rao M

  • 1,953 views
  • 0 comments
  • 4 respects

IR Remote Controlled Home Automation

Project tutorial by suhail jr

  • 11,504 views
  • 7 comments
  • 20 respects

Make an Enhanced R2-D2 to Be Controlled by an Android App

Project tutorial by Kutluhan Aktar

  • 2,334 views
  • 0 comments
  • 2 respects

Home Automation with Arduino Uno and SmartEdge Agile

Project tutorial by AYUSHMAN SAHA

  • 2,074 views
  • 0 comments
  • 4 respects
Add projectSign up / Login