Project tutorial
Password-Protected, Arduino-Controlled Servo Gate

Password-Protected, Arduino-Controlled Servo Gate © LGPL

This project is about servo motors which are controlled by a push button. The servo motors only work when a certain algorithm is followed.

  • 1,582 views
  • 0 comments
  • 8 respects

Components and supplies

About this project

This project is all about a password-protected gate. The gate is made up of two servo motors and opens up when a fixed algorithm is followed. The project consists of two servo motors, three LEDs, four push buttons (three for gate and one for reset purpose). When the algorithm is followed correctly, the gate opens. Algorithm is like this...

When push button 1 is pressed once keeping the 2 other pushbutton at off state. After this, pressing push button 1 and push button 3 at once and keeping push button 2 as it is. After this, pressing push button 2 and push button 3 at once and keeping push button 1 as it is. When this process is followed, the gate opens and all the LEDs glow. When push button 4 is pressed, all the values of push button gets 0 or reset.

Code

arduino code for password protected gate Arduino
#include<Servo.h>
Servo myservo;
Servo myservo1;

  int led1=5;
  int led2=6;
  int led3=7;
  int push1=2;
  int push2=3;
  int push3=4;
  int push4=A4;
  int counter1=0;
  int counter2=0;
  int counter3=0;
   int counter4=0;
  

void setup() {
  // put your setup code here, to run once:

  pinMode(led1,OUTPUT);
  pinMode(led2,OUTPUT);
  pinMode(led3,OUTPUT);
    pinMode(push1,INPUT);
        pinMode(push2,INPUT);
            pinMode(push3,INPUT);
             pinMode(push4,INPUT);
            Serial.begin(9600);
            myservo.attach(9);
          
                 myservo1.attach(10);
  

}

void loop() {
  int buttonState1=digitalRead(push1);
   int buttonState2=digitalRead(push2);
    int buttonState3=digitalRead(push3);
       int buttonState4=digitalRead(push4);
    
if(buttonState1==1){
  
  counter1=1;
  }
      
if(buttonState1==1 && buttonState3==1){
  
  counter2=2;
  }
  if(buttonState2==1 && buttonState3==1){
  
  counter3=3;
  }

if(buttonState4==1){
  
  counter4=4;
  
  }






    
Serial.println("counter2");
Serial.println(counter2);
delay(50);
Serial.println("counter1");
Serial.println(counter1);
delay(50);
Serial.println("counter3");
Serial.println(counter3);
delay(50);



if(counter1==1 && counter2==2 && counter3==3){
  digitalWrite(led1,HIGH);
  digitalWrite(led2,HIGH);
  digitalWrite(led3,HIGH);
  myservo.write(90);
    myservo1.write(0);
     
  
  
  
  }
  else{
      digitalWrite(led1,LOW);
  digitalWrite(led2,LOW);
  digitalWrite(led3,LOW);
  myservo.write(0);
    myservo1.write(75);
     
    
  
    
    
    }
    if(buttonState4==1){
      counter1=0;
      counter2=0;
      counter3=0;
      
      
      

      }
    

Serial.println("buttonState4");
Serial.println(buttonState4);
delay(50);

}




    

Schematics

arduino controlled password protected gate
circuit diagram
Servos 9juhwq4teb

Comments

Similar projects you might like

Servo Control with TV Remote Control

Project showcase by eldo85

  • 11,128 views
  • 5 comments
  • 32 respects

Morse Code Communication Using Arduino

Project tutorial by Jalal_Mansoori

  • 7,587 views
  • 17 comments
  • 30 respects

Servo Tuning Buttons

Project in progress by Andrew Hillier

  • 1,642 views
  • 0 comments
  • 8 respects

How to Use Modbus with Arduino

Project tutorial by hwhardsoft

  • 14,074 views
  • 4 comments
  • 19 respects

Simplest Way for Voice Recognition Project Using c#toarduino

Project tutorial by Jalal_Mansoori

  • 13,702 views
  • 30 comments
  • 58 respects

Create Mobile Apps for Android and iOS Connecting to the MKR

Project tutorial by Chandana Pathirage

  • 7,086 views
  • 4 comments
  • 17 respects
Add projectSign up / Login