Aws_Alkarmi
Published © GPL3+

Rotary Dial Disk (Rotary Phone) Password programmed

Let the old phone disk function in some thing new using the Gear motor to open the door

IntermediateFull instructions provided3,598
Rotary Dial Disk (Rotary Phone) Password programmed

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Geared DC Motor
×1
Rotary Dial Disk from old phone
×1
AA Batteries
AA Batteries
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

The Code Of The Project

Arduino
Any More Information Please let me know Down in the comments
  //Rotary Dial Disk 
                                                                                                             
//By Aws AlKarmi   //By Aws AlKarmi   //By Aws AlKarmi   //By Aws AlKarmi   //By Aws AlKarmi   //By Aws AlKarmi
// [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ 


 
       // Four Wires Out Of It ...... Two For Pulse Counting .... And .... Two For Ending The Digit 'Pulses' 


#define pulsePin 3         //Pulse Pin To Digital Pin 3 The Other To GND Ground
int number[7];             //Useing Array Way To Record The Number
#define signal1 7          //Signal Pin To Digital Pin 7 The Other To 5V Source
int currentDigit=0;         //Initializing By 0
int pulseCount=0;           //Initializing By 0
#define led LED_BUILTIN        //Working With The LED Built In
int state=1;                  //Initializing State 
int d=70;                    // The Delay Time For LED To Blink At The Wrong Password
int state2=0;               //Initializing State2
#define motor1 8           //The Main Pin To Work With
#define motor2 10         //The AUX Pin To Work With

void setup()
    {
      
    Serial.begin(9600);              //Begining The Serial
    pinMode(pulsePin,INPUT);         //pulsePin As INPUT
    pinMode(signal1,INPUT);          //signal   As INPUT
    pinMode(led,OUTPUT);             //led      As OUTPUT
    pinMode(motor1,OUTPUT);          //motor1   As OUTPUT
    pinMode(motor2,OUTPUT);          //motor2   As OUTPUT

   digitalWrite(led,LOW);       //Initializing First Command 'not necessary'
   digitalWrite(motor1,LOW);    //Initializing First Command 'not necessary'
   digitalWrite(motor2,HIGH);   //Initializing First Command 'not necessary'

   
    }
void loop(){                     //The Main Program
    
  if (digitalRead(signal1)==1&&state==1)    // Putting State 'Not Necessary'
 
     {
      if (digitalRead(pulsePin)!=0)         // If The Circuit Opened
      
          {
          delay(80);            // Debouncing Time 'Can Be Adjusted'
          pulseCount++;         // Count The Pulses         
          Serial.println(pulseCount);   // Print On Serial Monitor Expected Number From 1 To 10                          
          }           
     }
  else 
 if(digitalRead(signal1)!=1&&pulseCount>0)              // If Signal Not Equal 1 'The Pulses Stoped' 
       {                                                // AND Pulse Count Is More Than 0 'A Digit Entered'
         
        if (currentDigit<6)    //If The Number Of Digits Not Equal The Full Number Of Digits Then
          {
            Serial.print("  The Entered Digit .... ");         //Print On Serial Monitor
            Serial.println(pulseCount);                       //Print On Serial Monitor

            number[currentDigit]= pulseCount;                   //Recording The Digit Entered
            Serial.print("The Number Of Digits Entered Yet .... ");   //Print On Serial Monitor
            Serial.println(currentDigit+1);                       //Print On Serial Monitor
            Serial.print("The Digits Entered Yet .... ");             //Print On Serial Monitor The Password
            for(int i=0;i<7;i++)
              {
              Serial.print(number[i]);
              }
              
            Serial.println(" ...... By Aws Karmi ......");         // Print On Serial Monitor My Name
            currentDigit++;                      // The Next Digit To Record On
            pulseCount=0;                        // Reset The Pulses Counting 
            number[currentDigit]=0;              // Initializing The Next Digit By 0
            state2=1;                            // Putting State To 1           
          }
           if (currentDigit==6)                  //If we Exeed 6 Digits
                          {
 if (number[0]==4&&number[1]==3&&number[2]==4&&number[3]==3&&number[4]==2&&number[5]==2) //If The Digits Equal
           {                                                                             //The Right Password
             Serial.println(" ///////WRITE Answer//////");          //Print On Serial Monitor
             digitalWrite(motor1,HIGH);             //Open The Door
             digitalWrite(motor2,LOW);

             digitalWrite(led,HIGH);
             delay(1000);                            // LED AND Motor1 Work For 1 Second Delay
             digitalWrite(motor1,LOW);
             digitalWrite(motor2,HIGH);


             digitalWrite(led,LOW);
             delay(500);
             digitalWrite(led,HIGH);
             delay(500);
             digitalWrite(led,LOW);
             
           for (int i=0;i<7;i++)                           // Reset The Numbers 'Password'
              {
              number[i]=0;
              }
              
              state2=2;                                    //Putting State To 2  
              currentDigit=0;                              //Reset The Number Of Digits
              
            }else if(state2==1)                             // Checking The State Condition
        {
            for (int i=0;i<7;i++)                          // Reset The Numbers 'Password'
              {
              number[i]=0;
              }
              
                  Serial.println(" ///////WRONG Answer//////");                //Print On Serial Monitor
                     
                  for(int j=0;j<15;j++)                          // Blinking The LED
                  { 
                  digitalWrite(led,HIGH);
                  delay(d);
                  digitalWrite(led,LOW);
                  delay(d);
                  }
                      
            currentDigit=0;                                     //Reset The Number Of Digits
            
        }
            
            
            
                        }
        
        
        
        
      }
      

Credits

Aws_Alkarmi
5 projects • 3 followers

Comments