Project tutorial
Control your windows and Bust burglars

Control your windows and Bust burglars

Using a slider on your smartphone you could open or close your windows also using a sensor your smartphone buzzes in case of a thief.

  • 3,080 views
  • 0 comments
  • 5 respects

Components and supplies

About this project

Last summer was one of the hottest in my town and with great heat comes great laziness so I didn't even want to stand up and shut my own windows so I decided to control them using my smartphone and since I had lots of time on my hands, I decided to add a security system as well. In this project I used Arduino uno and 1Sheeld and here's why.

Arduino is the fastest prototyping board out there and it is really easy to use, the built in examples cover a wide range of applications and by integrating it with 1Sheeld almost anything is possible.

How to build this project?

1- Gather all the components mentioned in the Hardware section.

2- Connect them as shown in this picture or simply download the attached fritzing files.

3- Download the code in the software section.

4- Connect your Arduino Uno to your pc or laptop using a USB cable.

5- Check the getting started tutorial on the 1Sheeld website to make your build much easier.

6- Using the Arduino IDE compile the code and upload it

7- Download the 1Sheeld app on your smartphone and open your Bluetooth and scan for your 1Sheeld, the procedure is explained in detail in the getting started tutorial on 1Sheeld website.

8- Select the buzzer, toggle button, terminal, and slider shields.

Now you're done with the project whenever your hand gets too close the ultrasonic sensor the buzzer on your smartphone will be triggered given that you already activated this - flawless :D - security system using the toggle button shield, also you open your windows close them or even keep them slightly ajar using the slider shield.

One practical tip would be to hang your ultrasonic sensor slightly high so that it wouldn't go off when detecting a cat or a dog.

Happy Hacking everyone!

Code

CodeArduino
It is used to launch a buzzer on your smartphone whenever there is someone within a 10 cm range from your front door and control your windows using the slider in the 1Sheeld app.
#include <OneSheeld.h>
#include<Servo.h>
const int trig = 7;
const int echo = 6;
const int windowServoPin=9;
Servo windowServo;



void setup() {
  // initialize serial communication:
  OneSheeld.begin();
  Serial.begin(9600);
  windowServo.attach(windowServoPin);
  }
  
void loop() {
  // establish variables for duration of the ping,
  // and the distance result in inches and centimeters:
  long duration, inches, cm;

  // The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
  // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
  pinMode(trig, OUTPUT);
  digitalWrite(trig, LOW);
  delayMicroseconds(2);
  digitalWrite(trig, HIGH);
  delayMicroseconds(5);
  digitalWrite(trig, LOW);

  // The same pin is used to read the signal from the PING))): a HIGH
  // pulse whose duration is the time (in microseconds) from the sending
  // of the ping to the reception of its echo off of an object.
  pinMode(echo, INPUT);
  duration = pulseIn(echo, HIGH);

  // convert the time into a distance
  cm = microsecondsToCentimeters(duration);

  Terminal.print(cm);
  Terminal.print(" cm");
  Terminal.println();
  if (cm <= 10 & ToggleButton.getStatus()==1) {
    Buzzer.buzzOn();
  }
  else {
    Buzzer.buzzOff();
  }
  
   int value = Slider.getValue();
  value = map(value,0,255,0,180);
  windowServo.write(value);
}
long microsecondsToCentimeters(long microseconds) {
  // The speed of sound is 340 m/s or 29 microseconds per centimeter.
  // The ping travels out and back, so to find the distance of the
  // object we take half of the distance travelled.
  return microseconds / 29 / 2;
}

Schematics

Schematic
Fritzing schematic of the circuit
Windows%20servo%20and%20ultrasonic.fzz

Comments

Similar projects you might like

Control your RoboArm with your Smartphone

Project in progress by Team Zone Team

  • 9,164 views
  • 7 comments
  • 27 respects

Control your light system with your voice

Project tutorial by Maha Raafat

  • 36,236 views
  • 22 comments
  • 155 respects

Home Management System - Control your home from a website

Project tutorial by Ahmed El-Hinidy

  • 34,530 views
  • 22 comments
  • 122 respects

How to control your light switch from your smartphone?

Project in progress by Mahmoud Ahmed

  • 22,607 views
  • 3 comments
  • 15 respects

Servo Control with TV Remote Control

Project showcase by eldo85

  • 5,593 views
  • 5 comments
  • 17 respects

Control RGB LED by Dragging – Arduino 101 & App Inventor

Project tutorial by DFRobot and CAVEDU Education

  • 4,438 views
  • 0 comments
  • 12 respects
Add projectSign up / Login