DIY Inventor
Published

Arduino Bluetooth Controlled Solar Smart Security for Home

This project help us to get our life easier. It will detect many things and show the alert on our device which can controlled by Bluetooth

BeginnerFull instructions provided3,886
Arduino Bluetooth Controlled Solar Smart Security for Home

Things used in this project

Hardware components

Solar Panel 6V
×1
Capacitor 1000 µF
Capacitor 1000 µF
×1
1N4007 – High Voltage, High Current Rated Diode
1N4007 – High Voltage, High Current Rated Diode
×1
Water Sensor
×1
LDR, 5 Mohm
LDR, 5 Mohm
×1
Resistor 1k ohm
Resistor 1k ohm
×1
Arduino UNO
Arduino UNO
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
IR Sensor
×1
Buzzer
Buzzer
×1
5 mm LED: Red
5 mm LED: Red
×1
High Brightness LED, White
High Brightness LED, White
×1
Lead Acid Battery 6V
×1
Power Entry Connector, Tubular Connector Cable Assembly
Power Entry Connector, Tubular Connector Cable Assembly
×1

Software apps and online services

Arduino IDE
Arduino IDE
Bluetooth Electronics

Story

Read more

Schematics

Circuit Diagram

Code

Code

C/C++
char dataIn = 'S';
char determinant;
char det;

int irled = 6;
int irbuz = 9;
int ir = 2;
int tp = 13;
int trig = 3;
int echo = 4;
long duration;
int distance;
int ultraled = 7;
int ultrabuz = 11;
int rainled = 5;
int rainbuz = 8;
const int ledPin = 12; 
const int ldrPin = A1;



void setup() {
      Serial.begin(9600);
  Serial.println("Welcome");
  delay(500);
  Serial.println("Starting Smart Home System");
  Serial.println("Made By Krishna Team");
  delay(2000);
   pinMode(irled,OUTPUT);
  pinMode(irbuz,OUTPUT);
  pinMode(ir,INPUT);
  pinMode(tp,OUTPUT);
pinMode(trig, OUTPUT);
pinMode(echo, INPUT);


pinMode(ultrabuz,OUTPUT);
pinMode(ultraled,OUTPUT);
pinMode(rainled , OUTPUT);
   pinMode(rainbuz , OUTPUT);
     pinMode(ledPin, OUTPUT);  
  pinMode(ldrPin, INPUT);  

  
}

void loop() {
 digitalWrite(trig, LOW);
    delayMicroseconds(5);
    digitalWrite(trig, HIGH);
    delayMicroseconds(10);
    digitalWrite(trig, LOW);
  
    duration = pulseIn(echo, HIGH);
    distance = duration*0.034/2;
     if( digitalRead( ldrPin ) == 1){
      digitalWrite( ledPin,HIGH);
       }
   else{
      digitalWrite( ledPin , LOW);
   }
   
       
  det = check();
    switch (det){
      case 'A': 
   if (digitalRead(ir)== LOW){
    Serial.println("Alert Ir Detects Object");
    digitalWrite(irled , HIGH);
    digitalWrite(irbuz , HIGH);
     delay(10);
    }
      else
  digitalWrite(irled , LOW);
    digitalWrite(irbuz , LOW);
     delay(10);
          
det = check();
    break;

    case 'B':
      digitalWrite(tp,LOW);
      digitalWrite(irled , LOW);
    digitalWrite(irbuz , LOW);
det = check();
break;
case 'C' :
  if (digitalRead(ir)== LOW){
    Serial.println("Alert Ir Detects Object");
    digitalWrite(irled , LOW);
    digitalWrite(irbuz , LOW);
     delay(10);
  }
  else
  digitalWrite(irled , LOW);
    digitalWrite(irbuz , LOW);
     delay(10);
     
det = check();
break;
case 'D' :
    if (digitalRead(ir)== LOW){
    Serial.println("Alert Ir Detects Object");
    digitalWrite(irled , HIGH);
    digitalWrite(irbuz , HIGH);
     delay(10);
    }
      else
  digitalWrite(irled , LOW);
    digitalWrite(irbuz , LOW);
     delay(10);
  det = check();  
break;
    case 'E':
     if (distance <= 75){
    Serial.print(distance);
    Serial.println("cm  Extreme Risk ");
 digitalWrite(ultraled , HIGH);
 tone(ultrabuz,900);
  delay(900);
    digitalWrite(ultraled , LOW);
  noTone(ultrabuz);
  delay(900); 
     }

     else if (distance >= 76 && distance <=151){
     Serial.print(distance);
       Serial.println("cm  HIGH Risk");
digitalWrite(ultraled , HIGH);
  tone(ultrabuz,1400);
  delay(1400);
    digitalWrite(ultraled , LOW);
  noTone(ultrabuz);
  delay(1400);
  }

     else if (distance >= 152 && distance <=227){
    Serial.print(distance);
       Serial.println("cm  Medium Risk");
      digitalWrite(ultraled , HIGH);
  tone(ultrabuz,1500);
  delay(2000);
    digitalWrite(ultraled , LOW);
  noTone(ultrabuz);
  delay(2000);
     }
     
     else if (distance >= 228 && distance <=300){
    Serial.print(distance);
       Serial.println("cm  Low Risk");
      digitalWrite(ultraled , HIGH);
  tone(ultrabuz,2000);
  delay(3000);
    digitalWrite(ultraled , LOW);
  noTone(ultrabuz);
  delay(3000);
  }
     else
     digitalWrite(ultraled,LOW);
     digitalWrite(ultrabuz,LOW);

 det = check();
    break;
    
    case 'F':
   digitalWrite(ultraled,LOW);
     digitalWrite(ultrabuz,LOW);

Serial.print("");
 det = check();
    break;

  case 'G':
     if (distance <= 75){
     Serial.println("Extreme Risk");
   digitalWrite(ultraled,LOW);
     digitalWrite(ultrabuz,LOW);
  
     }

     else if (distance >= 76 && distance <=151){
     Serial.println("HIGH Risk");
   digitalWrite(ultraled,LOW);
     digitalWrite(ultrabuz,LOW);
  }

     else if (distance >= 152 && distance <=227){
        Serial.println("Medium Risk");
   digitalWrite(ultraled,LOW);
     digitalWrite(ultrabuz,LOW);

     }

    
     else if (distance >= 228 && distance <=300){
        Serial.println("Low Risk");
   digitalWrite(ultraled,LOW);
     digitalWrite(ultrabuz,LOW);

     }
     else
     digitalWrite(ultraled,LOW);
     digitalWrite(ultrabuz,LOW);

 det = check();
    break;

    case 'H': 
        int value1=analogRead(A0);

    if (value1<700){
    Serial.println("Raining Outside");
        digitalWrite(rainled , HIGH);
  tone(rainbuz,900);
  delay(2000);
    digitalWrite(rainled , LOW);
  noTone(rainbuz);
  delay(3000);
   }

  else
   digitalWrite(rainled , LOW);
   digitalWrite(rainbuz , LOW);
det = check();
break;
case 'I' :
   digitalWrite(rainled , LOW);
   digitalWrite(rainbuz , LOW);
det = check();
break;
 
    }
}


int check(){
  if (Serial.available() > 0){// if there is valid data in the serial port
    dataIn = Serial.read();// stores data into a varialbe
if (dataIn == 'A'){//Forward
      determinant = 'A';
    }
    else if (dataIn == 'B'){//Backward
      determinant = 'B';
    }
    else if (dataIn == 'C'){//Backward
      determinant = 'C';
    }
    else if (dataIn == 'D'){//Backward
      determinant = 'D';
    }
    else if (dataIn == 'E'){//Backward
      determinant = 'E';
    }
    else if (dataIn == 'F'){//Backward
      determinant = 'F';
    }
    else if (dataIn == 'G'){//Backward
      determinant = 'G';
    }
    else if (dataIn == 'H'){//Backward
      determinant = 'H';
    }
    else if (dataIn == 'I'){//Backward
      determinant = 'I';
    }
    else if (dataIn == 'J'){//Backward
      determinant = 'J';
    }
    else if (dataIn == 'K'){//Backward
      determinant = 'K';
    }
    }
  return determinant;
}

Credits

DIY Inventor

DIY Inventor

0 projects • 17 followers
Hello Guys, My name is Krishna Agarwal , and I'm passionate about Making DIY Projects. Here I make Arduino and Robotics related projects.

Comments