Components and supplies
Rotary Dial Disk from old phone
AA Batteries
Arduino UNO
Geared DC Motor
Apps and platforms
Arduino IDE
Project description
Code
The Code Of The Project
arduino
Any More Information Please let me know Down in the comments
1 //Rotary Dial Disk 2 3//By Aws AlKarmi //By Aws AlKarmi //By Aws AlKarmi //By Aws AlKarmi //By Aws AlKarmi //By Aws AlKarmi 4// [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ 5 6 7 8 // Four Wires Out Of It ...... Two For Pulse Counting .... And .... Two For Ending The Digit 'Pulses' 9 10 11#define pulsePin 3 //Pulse Pin To Digital Pin 3 The Other To GND Ground 12int number[7]; //Useing Array Way To Record The Number 13#define signal1 7 //Signal Pin To Digital Pin 7 The Other To 5V Source 14int currentDigit=0; //Initializing By 0 15int pulseCount=0; //Initializing By 0 16#define led LED_BUILTIN //Working With The LED Built In 17int state=1; //Initializing State 18int d=70; // The Delay Time For LED To Blink At The Wrong Password 19int state2=0; //Initializing State2 20#define motor1 8 //The Main Pin To Work With 21#define motor2 10 //The AUX Pin To Work With 22 23void setup() 24 { 25 26 Serial.begin(9600); //Begining The Serial 27 pinMode(pulsePin,INPUT); //pulsePin As INPUT 28 pinMode(signal1,INPUT); //signal As INPUT 29 pinMode(led,OUTPUT); //led As OUTPUT 30 pinMode(motor1,OUTPUT); //motor1 As OUTPUT 31 pinMode(motor2,OUTPUT); //motor2 As OUTPUT 32 33 digitalWrite(led,LOW); //Initializing First Command 'not necessary' 34 digitalWrite(motor1,LOW); //Initializing First Command 'not necessary' 35 digitalWrite(motor2,HIGH); //Initializing First Command 'not necessary' 36 37 38 } 39void loop(){ //The Main Program 40 41 if (digitalRead(signal1)==1&&state==1) // Putting State 'Not Necessary' 42 43 { 44 if (digitalRead(pulsePin)!=0) // If The Circuit Opened 45 46 { 47 delay(80); // Debouncing Time 'Can Be Adjusted' 48 pulseCount++; // Count The Pulses 49 Serial.println(pulseCount); // Print On Serial Monitor Expected Number From 1 To 10 50 } 51 } 52 else 53 if(digitalRead(signal1)!=1&&pulseCount>0) // If Signal Not Equal 1 'The Pulses Stoped' 54 { // AND Pulse Count Is More Than 0 'A Digit Entered' 55 56 if (currentDigit<6) //If The Number Of Digits Not Equal The Full Number Of Digits Then 57 { 58 Serial.print(" The Entered Digit .... "); //Print On Serial Monitor 59 Serial.println(pulseCount); //Print On Serial Monitor 60 61 number[currentDigit]= pulseCount; //Recording The Digit Entered 62 Serial.print("The Number Of Digits Entered Yet .... "); //Print On Serial Monitor 63 Serial.println(currentDigit+1); //Print On Serial Monitor 64 Serial.print("The Digits Entered Yet .... "); //Print On Serial Monitor The Password 65 for(int i=0;i<7;i++) 66 { 67 Serial.print(number[i]); 68 } 69 70 Serial.println(" ...... By Aws Karmi ......"); // Print On Serial Monitor My Name 71 currentDigit++; // The Next Digit To Record On 72 pulseCount=0; // Reset The Pulses Counting 73 number[currentDigit]=0; // Initializing The Next Digit By 0 74 state2=1; // Putting State To 1 75 } 76 if (currentDigit==6) //If we Exeed 6 Digits 77 { 78 if (number[0]==4&&number[1]==3&&number[2]==4&&number[3]==3&&number[4]==2&&number[5]==2) //If The Digits Equal 79 { //The Right Password 80 Serial.println(" ///////WRITE Answer//////"); //Print On Serial Monitor 81 digitalWrite(motor1,HIGH); //Open The Door 82 digitalWrite(motor2,LOW); 83 84 digitalWrite(led,HIGH); 85 delay(1000); // LED AND Motor1 Work For 1 Second Delay 86 digitalWrite(motor1,LOW); 87 digitalWrite(motor2,HIGH); 88 89 90 digitalWrite(led,LOW); 91 delay(500); 92 digitalWrite(led,HIGH); 93 delay(500); 94 digitalWrite(led,LOW); 95 96 for (int i=0;i<7;i++) // Reset The Numbers 'Password' 97 { 98 number[i]=0; 99 } 100 101 state2=2; //Putting State To 2 102 currentDigit=0; //Reset The Number Of Digits 103 104 }else if(state2==1) // Checking The State Condition 105 { 106 for (int i=0;i<7;i++) // Reset The Numbers 'Password' 107 { 108 number[i]=0; 109 } 110 111 Serial.println(" ///////WRONG Answer//////"); //Print On Serial Monitor 112 113 for(int j=0;j<15;j++) // Blinking The LED 114 { 115 digitalWrite(led,HIGH); 116 delay(d); 117 digitalWrite(led,LOW); 118 delay(d); 119 } 120 121 currentDigit=0; //Reset The Number Of Digits 122 123 } 124 125 126 127 } 128 129 130 131 132 } 133
Comments
Only logged in users can leave comments