|
| 1 | +int m11=7; |
| 2 | +int m12=9; |
| 3 | +int D0=0; |
| 4 | +int D1=0; |
| 5 | +int D2=0; |
| 6 | +int D3=0; |
| 7 | +int m[4]; |
| 8 | +int n[4]; |
| 9 | +int p[4]; |
| 10 | + |
| 11 | +// Already setted Correct Password for unlock |
| 12 | + |
| 13 | +int password[4][4]={{0,0,0,1}, |
| 14 | + {0,0,1,0}, |
| 15 | + {0,0,1,1}, |
| 16 | + {0,1,0,0}}; |
| 17 | + ///////////// |
| 18 | + |
| 19 | +//// Array for Receiving entered passwords by user |
| 20 | + int input[4][4]; |
| 21 | + |
| 22 | +////////////// |
| 23 | + int c[4]; |
| 24 | + int u[4]={1,0,0,1}; |
| 25 | + bool led = false; |
| 26 | +void setup() { |
| 27 | + // put your setup code here, to run once: |
| 28 | + |
| 29 | +pinMode(3,INPUT);//dtmf pin |
| 30 | +pinMode(4,INPUT);//dtmf pin |
| 31 | +pinMode(5,INPUT); //dtmf pin |
| 32 | +pinMode(6,INPUT); //dtmf pin |
| 33 | +pinMode(7,OUTPUT); |
| 34 | +pinMode(9,OUTPUT); |
| 35 | +pinMode(10,OUTPUT); |
| 36 | +pinMode(12,OUTPUT); |
| 37 | +pinMode(13, OUTPUT);//bluetooth*/ |
| 38 | +Serial.begin(9600); |
| 39 | +} |
| 40 | +void loop() { |
| 41 | + // put your main code here, to run repeatedly: |
| 42 | + |
| 43 | + label : // catches the thrown of code |
| 44 | +int count=0; |
| 45 | + int i=0,j=0,k=0; |
| 46 | + D0=digitalRead(3); |
| 47 | + D1=digitalRead(4); |
| 48 | + D2=digitalRead(5); |
| 49 | + D3=digitalRead(6); |
| 50 | + |
| 51 | +Serial.print(D3); |
| 52 | +Serial.print("\t"); |
| 53 | +Serial.print(D2); |
| 54 | +Serial.print("\t"); |
| 55 | +Serial.print(D1); |
| 56 | +Serial.print("\t"); |
| 57 | +Serial.print(D0); |
| 58 | +Serial.print("\n"); |
| 59 | +if(D3==1 && D2==0 && D1==1 && D0==1) |
| 60 | +{ |
| 61 | + while(1) |
| 62 | + { Serial.println("******in while loop******"); |
| 63 | + // delay(10000); |
| 64 | + // Reading inputs of key pressed through DTMF pins |
| 65 | + D0=digitalRead(3); |
| 66 | + D1=digitalRead(4); |
| 67 | + D2=digitalRead(5); |
| 68 | + D3=digitalRead(6); |
| 69 | + |
| 70 | + |
| 71 | + if(D3==1 && D2==0 && D1==1 && D0==1) ///**** |
| 72 | + { |
| 73 | + } |
| 74 | + else{ |
| 75 | + |
| 76 | + if(D3==1 && D2==1 && D1==0 && D0==0) //##### |
| 77 | + { // comparision; |
| 78 | + if(k<4) |
| 79 | + { |
| 80 | + for(k=0; k<4; k++) |
| 81 | + { Serial.println("******locked******"); |
| 82 | + |
| 83 | + if(password[k][0]==input[k][3] && password[k][1]==input[k][2] && password[k][2]==input[k][1] && password[k][3]==input[k][0]) |
| 84 | + {count++;} /////// Comparing entered and already setted password |
| 85 | + |
| 86 | + } // comparision for ends |
| 87 | + |
| 88 | + Serial.println("count==== "); |
| 89 | + Serial.println(count); |
| 90 | + if(count==4) |
| 91 | + { led= !led; |
| 92 | + if(led==true) |
| 93 | + { |
| 94 | + digitalWrite(7,HIGH); |
| 95 | + digitalWrite(9,LOW); |
| 96 | + Serial.println("locked"); |
| 97 | + delay(550); |
| 98 | + |
| 99 | + digitalWrite(7,LOW); |
| 100 | + digitalWrite(9,LOW); |
| 101 | + goto label; } |
| 102 | + else if(led==false) |
| 103 | + {goto label;} |
| 104 | + } // count if ends |
| 105 | + } // k<4 if ends |
| 106 | + else if(u[0]==c[3] && u[1]==c[2] && u[2]==c[1] && u[3]==c[0]) |
| 107 | + { |
| 108 | + led= !led; |
| 109 | + digitalWrite(7,LOW); |
| 110 | + digitalWrite(9,HIGH); |
| 111 | + Serial.println("locked"); |
| 112 | + delay(550); |
| 113 | + |
| 114 | + digitalWrite(7,LOW); |
| 115 | + digitalWrite(9,LOW); |
| 116 | + goto label; } |
| 117 | + |
| 118 | + else |
| 119 | + {goto label; |
| 120 | + } |
| 121 | + |
| 122 | + |
| 123 | + } // ### if condition ends |
| 124 | + else{ |
| 125 | + m[0]=D0; |
| 126 | + m[1]=D1; |
| 127 | + m[2]=D2; |
| 128 | + m[3]=D3; |
| 129 | + |
| 130 | + // delay(5000); } |
| 131 | + if(i<1) |
| 132 | + { |
| 133 | + p[0]=D0; |
| 134 | + p[1]=D1; |
| 135 | + p[2]=D2; |
| 136 | + p[3]=D3; |
| 137 | + c[0]=D0; |
| 138 | + c[1]=D1; |
| 139 | + c[2]=D2; |
| 140 | + c[3]=D3; |
| 141 | + |
| 142 | + //// Setting entered password |
| 143 | + input[j][0]=p[0]; |
| 144 | + input[j][1]=p[1]; |
| 145 | + input[j][2]=p[2]; |
| 146 | + input[j][3]=p[3]; |
| 147 | + ////////////////////////////////////// |
| 148 | + |
| 149 | + j++; |
| 150 | + i++; |
| 151 | + } // if i<1 condition ends |
| 152 | + |
| 153 | + if(m[3]==p[3] && m[2]==p[2] && m[1]==p[1] && m[0]==p[0]) |
| 154 | + { } |
| 155 | + else |
| 156 | + {i=0;} // upgrading of i ends |
| 157 | + |
| 158 | + |
| 159 | + } // ### else ends |
| 160 | + } /// *** else ends |
| 161 | + } // while loop |
| 162 | + } // if **** |
| 163 | +} // void loop |
0 commit comments