element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Embedded and Microcontrollers
  • Technologies
  • More
Embedded and Microcontrollers
Embedded Forum Do you have a question on Embedded electronics and controls? Ask our Expert, Paul Clarke
  • Blog
  • Forum
  • Documents
  • Quiz
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Embedded and Microcontrollers to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 126 replies
  • Subscribers 508 subscribers
  • Views 10638 views
  • Users 0 members are here
  • skills
  • c
  • hvac
  • digital
  • engineer
  • expert
  • microprocessor
  • answer
  • control
  • thermal_management
  • embedded_system
  • embedded
  • thermal
  • electronics
  • paul_clarke
  • assembly
  • solutions
  • rac
  • software
  • develop
  • question
Related

Do you have a question on Embedded electronics and controls? Ask our Expert, Paul Clarke

pjclarke
pjclarke over 15 years ago

This thread has been closed to new questions.

However, we welcome you to Post Your Question about Embedded in the element14 Community Embedded group. You'll find many fellow members and experts who have just the answer you're looking to find! 

 

Thank You, Your Friends at element14 Community

image

Paul Clarke

Paul has 20+ years of working as a digital electronics engineer and has strong software skills in assembly and C for embedded systems. Currently developing embedded electronics for thermal management control solutions for the air movement industry (HVAC & RAC).




  • Sign in to reply
  • Cancel
Parents
  • e14 Contributor
    e14 Contributor over 13 years ago

    Hello Mr. Clarke

    Im working on a simple project...and the name of my project is ELECTRONIC CODE LOCK SECURITY SYSTEM.

    my problem is that i have written the source code for this project to burn it in my microcontroller.....but i have to add some additional features to it.......when i turn on the power supply...i have to enter the password and again confirm the password.......then my microcontroller asks for the typed password...if i fail to enter the correct password three times, it shows PASSWORD WRONG NO MORE TRIALS LEFT....but if i enter the correct password it shows LOCK OPEN....now i have to make it more interesting....i have to add password change option in my source code...so can u help me out on this...???

    My source code is as follows :

     

    //Program to make a code lock with user defined password

     

     

    #include<reg51.h>

    #define port P1

    #define dataport P2

    #define key P0

    #define sec 100

    sbit rs = port^0;

    sbit rw = port^1;

    sbit en = port^2;

     

     

    sbit col1=key^4;

    sbit col2=key^5;

    sbit col3=key^6;

    sbit row1=key^0;

    sbit row2=key^1;

    sbit row3=key^2;

    sbit row4=key^3;

    sbit lock_output=P0^7;

     

     

    int check=0;

    int digit[4]={0,0,0,0};

    int dig_input[4]={0,0,0,0};

    int dig_input_recheck[4]={0,0,0,0};

     

     

    int i,k;

     

     

     

     

    void delay(unsigned int msec) // Time delay function

    {

    int i,j ;

    for(i=0;i<msec;i++)

      for(j=0;j<1275;j++);

    }

     

     

    void lcd_cmd(unsigned char item) // Function to send command to LCD

    {

    dataport = item;

    rs= 0;

    rw=0;

    en=1;

    delay(1);

    en=0;

    return;

    }

     

     

    void lcd_data(unsigned char item) // Function to send data to LCD

    {

    dataport = item;

    rs= 1;

    rw=0;

    en=1;

    delay(1);

    en=0;

    return;

    }

     

     

    void lcd_data_string(unsigned char *str) // Function to send data to string

    {

    int i=0;

    while(str[i]!='\0')

    {

      lcd_data(str[i]);

      i++;

      //delay(10);

    }

    return;

    }

     

     

    void lcd(unsigned char str[10])

    {

    lcd_cmd(0x38);

    lcd_cmd(0x0e);

    lcd_data_string(str);

    }

     

     

     

     

    void ans()

    {

    if(check>3)

    {

      lcd_cmd(0x01);

      lcd_cmd(0x82);

      lcd_data_string(" LOCK OPEN");

      lock_output=1;

      delay(300);

      while(1);

      }

    else

    {

      lcd_cmd(0x01);

      lcd_cmd(0x82);

      lcd_data_string(" WRONG PASSWORD");

      lock_output=0;

      delay(300);

    }                  

    }

     

     

    void code_check() // Function to check password

    {

    if(i<=3 )

    {

      switch((i+1))

      {

       case 1: {

          if(dig_input[0]==digit[0])

          {

           check=check+1;

          }

          break;

         }

       case 2: {

          if(dig_input[1]==digit[1])

          {

           check=check+1;

          }

          break;

         }

       case 3: {

          if(dig_input[2]==digit[2])

          {

           check=check+1;

          }

          break;

         }

       case 4: {

          if(dig_input[3]==digit[3])

          {

           check=check+1;

          }

          break;

         }

      }

    }

    delay(10);

    if(i==3)

    {

      ans();

    }

    }

     

     

    void display(int a) //Display function

    {

    switch(a)

    {

      case 1:{

        lcd_data('*');

        delay(100);

        digit[i]=1;

        code_check();

        break;

        }

      case 2:{

        lcd_data('*');

        delay(100);

        digit[i]=2;

        code_check();

        break;

        }

      case 3:{

        lcd_data('*');

        delay(100);

        digit[i]=3;

        code_check();

        break;

        }

      case 4:{

        lcd_data('*');

        delay(100);

        digit[i]=4;

        code_check();

        break;

        }

      case 5:{

        lcd_data('*');

        delay(100);

        digit[i]=5;

        code_check();

        break;

        }

      case 6:{

        lcd_data('*');

        delay(100);

        digit[i]=6;

        code_check();

        break;

        }

      case 7:{

        lcd_data('*');

        delay(100);

        digit[i]=7;

        code_check();

        break;

        }

      case 8:{

        lcd_data('*');

        delay(100);

        digit[i]=8;

        code_check();

        break;

        }

      case 9:{

        lcd_data('*');

        delay(100);

        digit[i]=9;

        code_check();

        break;

        }

      case 0:{

        lcd_data('*');

        delay(100);

        digit[i]=0;

        code_check();

        break;

        }

    }

    }

     

     

    void check_col1()

    {

    row1=row2=row3=row4=1;

    row1=0;

    if(col1==0)

    display(1);

    row1=1;

    row2=0;

    if(col1==0)

    display(4);

    row2=1;

    row3=0;

    if(col1==0)

    display(7);

    row3=1;

    row4=0;

    if(col1==0)

    {

      row4=1;

    }

    }

     

     

    void check_col2()

    {

    row1=row2=row3=row4=1;

    row1=0;

    if(col2==0)

    display(2);

    row1=1;

    row2=0;

    if(col2==0)

    display(5);

    row2=1;

    row3=0;

    if(col2==0)

    display(8);

    row3=1;

    row4=0;

    if(col2==0)

    display(0);

    row4=1;

    }

     

     

    void check_col3()

    {

    row1=row2=row3=row4=1;

    row1=0;

    if(col3==0)

    display(3);

    row1=1;

    row2=0;

    if(col3==0)

    display(6);

    row2=1;

    row3=0;

    if(col3==0)

    display(9);

    row3=1;

    row4=0;

    if(col3==0)

    {

      row4=1;

    }

    }

     

     

     

     

    void check_password_col1()

    {

    row1=row2=row3=row4=1;

    row1=0;

    if(col1==0)

    dig_input[k]=1;

    row1=1;

    row2=0;

    if(col1==0)

    dig_input[k]=4;

    row2=1;

    row3=0;

    if(col1==0)

    dig_input[k]=7;

    row3=1;

    row4=0;

    if(col1==0)

    {

      row4=1;

    }

    }

     

     

    void check_password_col2()

    {

    row1=row2=row3=row4=1;

    row1=0;

    if(col2==0)

    dig_input[k]=2;

    row1=1;

    row2=0;

    if(col2==0)

    dig_input[k]=5;

    row2=1;

    row3=0;

    if(col2==0)

    dig_input[k]=8;

    row3=1;

    row4=0;

    if(col2==0)

    {

      dig_input[k]=0;

      row4=1;

    }

    }

     

     

     

     

    void check_password_col3()

    {

    row1=row2=row3=row4=1;

    row1=0;

    if(col3==0)

    dig_input[k]=3;

    row1=1;

    row2=0;

    if(col3==0)

    dig_input[k]=6;

    row2=1;

    row3=0;

    if(col3==0)

    dig_input[k]=9;

    row3=1;

    row4=0;

    if(col3==0)

    {

      row4=1;

    }

    }

     

     

    void pass_set()

    {

    row1=row2=row3=row4=0;

    while(col1==1 && col2==1 && col3==1);

    for(i=0;i<4;i++)

    {

      k=i;

      delay(50);

      lcd_cmd(0xc4+i);

      delay(100);

      row1=row2=row3=row4=0;

      while(col1==1 && col2==1 && col3==1);

      row1=row2=row3=row4=0;

      if(col1==0)

      check_password_col1();

      else

       if(col2==0)

       check_password_col2();

       else

        if(col3==0)

        check_password_col3();

      lcd_data('*');

      delay(50);

    }

    }

     

     

    void main()

    {

    int e,j=0,count=1;

    col1=col2=col3=1;

    //FOR PASSWoRD INPUT

    do

    {

      lcd_cmd(0x01);  //Clear LCD screen

      lcd_cmd(0x81); 

      lcd("ENTER PASSWORD:");

      pass_set();

      for(e=0;e<4;e++)

      dig_input_recheck[e]=dig_input[e];

      lcd_cmd(0x01);

      lcd("CONFIRM PASSWORD:");

      pass_set();

      for(e=0;e<4;e++)

      {

       if(dig_input_recheck[e]==dig_input[e])

       j++;

      }

      if(j<4)

      {

       lcd_cmd(0x01);

       lcd_cmd(0x85);

       lcd("PASSWORD");

       lcd_cmd(0xC2);

       lcd("NOT MATCH");

       delay(300);

      }

    }

    while(j<4);

       

    while(count<4)          //Code input and check

    {

      lcd_cmd(0x01);

      lock_output=0;

      lcd_cmd(0x82); 

      lcd("ENTER PASSWORD");

      check=0;

      row1=row2=row3=row4=0;

      while(col1==1 && col2==1 && col3==1);

      for(i=0;i<4;i++)

      {

       delay(100);

       lcd_cmd(0xc4+i);

       row1=row2=row3=row4=0;

       while(col1==1 && col2==1 && col3==1);

       row1=row2=row3=row4=0;

       if(col1==0)

       check_col1();

       else

        if(col2==0)

        check_col2();

        else

         if(col3==0)

         check_col3();

      }

      count++;

      delay(1);  

    }

     

     

    if(count==4)

    {

      lcd_cmd(0x01);

      lcd_cmd(0x86);

      lcd("SORRY");

      lcd_cmd(0xc1);

      lcd("NO MORE TRIALS");

      while(1);

    }

    }

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • e14 Contributor
    e14 Contributor over 13 years ago in reply to e14 Contributor

    Could you please tell me or send me the details of your project " ELECTRONIC CODE LOCK SECURITY SYSTEM " ? Details like Circuit Diagram and Components used in the circuit. My email ID is razkr321@gmail.com . After understanding the complete project I can understand what changes should be done in programming.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • e14 Contributor
    e14 Contributor over 13 years ago in reply to e14 Contributor

    Could you please tell me or send me the details of your project " ELECTRONIC CODE LOCK SECURITY SYSTEM " ? Details like Circuit Diagram and Components used in the circuit. My email ID is razkr321@gmail.com . After understanding the complete project I can understand what changes should be done in programming.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube