ahmed ismail
Published © CERN-OHL

Unlock Your Door With a Hand Gesture

Using gesture recognition technology to open door locks.

BeginnerFull instructions provided2 hours1,744

Things used in this project

Hardware components

1Sheeld
1Sheeld
×1
Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
Servos (Tower Pro MG996R)
micro
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Schematic

Code

FWGORKNIRXT8IHA.ino

C/C++
//the code is made to unlock a door with a specific gesture 
// if you need help or want to contact me regarding the project you can do that at :adham.negm@ieee.org

#define CUSTOM_SETTINGS
#define INCLUDE_ACCELEROMETER_SENSOR_SHIELD
#define INCLUDE_TERMINAL_SHIELD
#define INCLUDE_BUZZER_SHIELD



/* Include 1Sheeld library. */
#include <OneSheeld.h>
#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position

int state=0;   //marks the state of the phone



void setup() {
  /* Start communication. */
  OneSheeld.begin();
    myservo.attach(10);  // attaches the servo on pin 10 to the servo object


}

void loop() {


  while(state==0){
     Terminal.println(AccelerometerSensor.getX());// print accelerometer values to the terminal shield for debugging purposes
    if(AccelerometerSensor.getX() > 5)
    {Terminal.println("A");
    state =1;}
  }

    
    while (state==1){
      
                  Terminal.println(AccelerometerSensor.getX()); // print accelerometer values to the terminal shield for debugging purposes
                 if(AccelerometerSensor.getX() > 8)
                   {Terminal.println("B");
                      state =2;}
    }


    while (state==2){
                  Terminal.println(AccelerometerSensor.getY()); // print accelerometer values to the terminal shield for debugging purposes
                  if(AccelerometerSensor.getY() > 5)
                  {Terminal.println("C");
                   state =3;}
      }


       while (state==3){
                  Terminal.println(AccelerometerSensor.getY()); // print accelerometer values to the terminal shield for debugging purposes
                  if(AccelerometerSensor.getY() > 8)
                  {Terminal.println("D");
                      Buzzer.buzzOn();
                      // Door Opens
                      for (pos = 0; pos <= 50; pos += 1) { // goes from 0 degrees to 180 degrees
                                                                 // in steps of 1 degree
                       myservo.write(pos);              // tell servo to go to position in variable 'pos'
                         delay(15);                       // waits 15ms for the servo to reach the position
                                                            }
                        Buzzer.buzzOff();
                        delay(10000);
                        Buzzer.buzzOn();

                      
                      //Door Closes
                      for (pos = 50; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
                           myservo.write(pos);              // tell servo to go to position in variable 'pos'
                             delay(15);}
                      Buzzer.buzzOff();

                   state =0;}
      }


  



}

Credits

AdhamN

Posted by ahmed ismail
Thanks to AdhamN.

Comments