Safety Lock

SRJT09204

Jugaadu visited Rahul's house when his father was scolding him. Jugaadu asked Uncle for the reason to scold Rahul?br

Bag Items:

  1. Servo Motor
  2. Capacitive Touch sensor
  3. Scissor
  4. Arduino UNO UNO
  5. Jumper Cables
  6. USB cable
  7. 12V Battery
  8. Cardboard box
  9. Foam Sheets
  10. Glue gun
  11. Tape
  12. Cutter
  13. Icecream Sticks
To hide the television remote a locker can be made with the help of a touch switch. We can set a password on the locker accordingly. With the help of servo, we can create a gate to close the box. When you enter the right password, the servo will move and the door will open.

    #include 
Servo S;
String password="1314";
String dial="";
int pin1=2;int pin2=3;int pin3=4;int pin4=5;
int pos=9; int r=8; int g=10; int b=11;
void setup() {
pinMode(pos,OUTPUT);
pinMode(r,OUTPUT);
pinMode(g,OUTPUT);
pinMode(b,OUTPUT);
S.attach(6);
pinMode(pin1,INPUT);
pinMode(pin2,INPUT);
pinMode(pin3,INPUT);
pinMode(pin4,INPUT);
digitalWrite(pos,1);
Serial.begin(9600);
Serial.println("Press a key");
}

void loop() {
digitalWrite(r,1);
digitalWrite(g,1);
digitalWrite(b,0);
S.write(0);
if(dial.length()<4){
if(digitalRead(pin1)){
dial=dial+"1";
delay(500);
}else if(digitalRead(pin2)){
dial=dial+"2";
delay(500);
}else if(digitalRead(pin3)){
dial=dial+"3";
delay(500);
}else if(digitalRead(pin4)){
dial=dial+"4";
delay(500);
}else{ 
} 
}else{
if (dial==password && dial!=""){
Serial.println("Open");
S.write(180);
digitalWrite(r,1);
digitalWrite(g,0);
digitalWrite(b,1);
dial="";
delay(5000);
}else{
Serial.println("wrong");
Serial.println(dial);
digitalWrite(r,0);
digitalWrite(g,1);
digitalWrite(b,1);
dial="";
delay(5000);
}
}
}