Skip to main content

Password Security





  • Aim: To make a Password Security System using ATmega16 microcontroller, LCD (16x2), Keypad (4x3) and motor.
NOTE: Motor needs L293D IC ( I have not used it for the simulation).
  • Code:
#define F_CPU 8000000UL
#include<avr/io.h>
#include<util/delay.h>
void initialize();
void lcd_cmd(char value);
void lcd_data(char value);
void lcd_string(char *str);
void lcd_num(unsigned int number);
void motor();
void initialize()
{
lcd_cmd(0x01); //clear LCD
lcd_cmd(0x02);    //home position
lcd_cmd(0x06);    //L-R
//lcd_cmd(0x04);
lcd_cmd(0x28); //4 bit mode
lcd_cmd(0x0C);    //character generation
}

void lcd_cmd(char value)
{
int un,ln; // pc7-pc4 = un ; pc3-pc4 =ln
un=value&0xF0; // & is anding function
PORTC=0x04|un;
_delay_ms(2);
PORTC=0x00|un;
_delay_ms(2);
ln=(value<<4)&0xF0; //<<=left shif by 4 bits
_delay_ms(2);
PORTC=0x04|ln;
_delay_ms(2);
PORTC=0x00|ln;
}

void lcd_data(char value)
{
int un,ln; // pc7-pc4 = un ; pc3-pc4 =ln
un=value&0xF0; // & is anding function
PORTC=0x05|un;
_delay_ms(2);
PORTC=0x01|un;
_delay_ms(2);
ln=(value<<4)&0xF0; //<<=left shif by 4 bits
_delay_ms(2);
PORTC=0x05|ln;
_delay_ms(2);
PORTC=0x01|ln;
}

void lcd_string(char *str)
{
int i=0;
while(str[i]!='\0')
{
lcd_data(str[i]);
i++;
}
}

void lcd_num(unsigned int number)
{
lcd_cmd(0x04);
int d=0;
while(number!=0)
{
d=number%10;
lcd_data(d+48);
number=number/10;
}
}

void motor(){
DDRA=0xFF;
PORTA=0xFE;

}

int pass=1234;
int ar[4];
void main()
{
DDRC=0xFF;
initialize();
int i=0;
DDRD=0x00;
DDRB=0xFF;

lcd_cmd(0xC0);
lcd_string("Enter Password");

while(1)
{

PORTD=0x0F;
PORTB=0x06;

if(PIND==0x0E)
{
lcd_cmd(0x80+i);
lcd_string("1");
_delay_ms(200);
ar[i]=1;
i++;

}

else if(PIND==0x0D){
lcd_cmd(0x80+i);
lcd_string("4");
_delay_ms(200);
ar[i]=4;

i++;

}

else if(PIND==0x0B){
lcd_cmd(0x80+i);
lcd_string("7");
_delay_ms(200);
ar[i]=7;

i++;

}
else if(PIND==0x07){
lcd_cmd(0x80+i);
lcd_string("*");
_delay_ms(200);
ar[i]=11;

i++;

}

PORTD=0x0F;
PORTB=0x05;

if(PIND==0x0E){
lcd_cmd(0x80+i);
lcd_string("2");
_delay_ms(200);
ar[i]=2;

i++;

}
else if(PIND==0x0D){
lcd_cmd(0x80+i);
lcd_string("5");
_delay_ms(200);
i++;

}

else if(PIND==0x0B){
lcd_cmd(0x80+i);
lcd_string("8");
_delay_ms(200);
ar[i]=8;

i++;

}
else if(PIND==0x07){
lcd_cmd(0x80+i);
lcd_string("0");
_delay_ms(200);
ar[i]=0;

i++;}

PORTD=0x0F;
PORTB=0x03;

if(PIND==0x0E){
lcd_cmd(0x80+i);
lcd_string("3");
_delay_ms(200);
ar[i]=3;

i++;

}
else if(PIND==0x0D){
lcd_cmd(0x80+i);
lcd_string("6");
_delay_ms(200);
ar[i]=6;

i++;

}

else if(PIND==0x0B){
lcd_cmd(0x80+i);
lcd_string("9");
_delay_ms(200);
ar[i]=9;

i++;

}
else if(PIND==0x07){
if(ar[0]==1 && ar[1] ==2 && ar[2]==3 && ar[3]==4){
lcd_data(0x00);
lcd_cmd(0xC0);
lcd_string("password correct");
motor();

}
else {
lcd_cmd(0xC0);
lcd_string("Pass incorrect");
}

}


}
}


  • Hardware information: 
Port B and D= Keypad
PortC = LCD display
Port A= Motor
Password set: 1234
  • Proteus Simulation:

Password security Simulation


  •  Constraints: 
1) To reset, Close the program and the restart.
2)Motor needs external Power
3) Password can't be reset externally


  • Conclusion: 
Password Security Systems has been created using C programming in Avr studio software and simulation of the same in proteus software. The simulation picture is shown above and the constraints have been noted.

Comments

Popular posts from this blog

Python Ping Pong Game

Game: Ping Pong Libraries used: 1) pygame  2) Math 3) Random Version: Python 3.7 Python Code: -------------------------------------------------------------------------------------------------------------------------- import pygame import math import random pygame.init() dis=pygame.display.set_mode((600,400)) gameover=False white=(255,255,255) black=(0,0,0) red=(255,0,0) blue=(0,0,255) col=(0,255,0) x1=575 y1=200 dx1=0 dy1=0 x2=25 y2=185 dx2=1 dy2=0 c=0 t=0 font_style = pygame.font.SysFont(None, 50) def message(msg,color):     mesg = font_style.render(msg, True, color)     dis.blit(mesg, [300, 200]) font_style1 = pygame.font.SysFont(None, 30)    def show(msg,color):     mesg = font_style1.render(msg, True, color)     dis.blit(mesg, [300, 10])    clock=pygame.time.Clock() while not gameover:     for event in pygame.event.get():       ...

LED Matrix

Aim: To display a character or letter on a 8x8 LED matrix. Code: #define F_CPU 8000000UL #include<avr/io.h> #include<util/delay.h> int main(){ DDRC=0xFF; DDRD=0xFF; DDRB=0x00; while(1){ if(PINB==0x01){ PORTC=0x08; PORTD=0xEF; _delay_ms(100); PORTC=0x1C; PORTD=0xC7; _delay_ms(100); PORTC=0x3E; PORTD=0x83; _delay_ms(100); PORTC=0x7F; PORTD=0x01; _delay_ms(100); PORTC=0xFF; PORTD=0x00; _delay_ms(100); PORTC=0x7F; PORTD=0x01; _delay_ms(100); PORTC=0x3E; PORTD=0x83; _delay_ms(100); PORTC=0x1C; PORTD=0xC7; _delay_ms(100); PORTC=0x08; PORTD=0xEF; _delay_ms(100); } else if(PINB==0x02){ PORTC=0x02; PORTD=0xF0; _delay_ms(1); PORTC=0x04; PORTD=0xEF; _delay_ms(1); PORTC=0x08; PORTD=0xDF; _delay_ms(1); PORTC=0x10; PORTD=0xBF; _delay_ms(1); PORTC=0x20; PORTD=0xDF; _delay_ms(1); PORTC=0x40; PORTD=0xEF; _delay_ms(1); PORTC=0x80; PORTD=0xF0; _delay_ms(1); }}} Proteus Simulation: LED matrix simulatio...

Calculator

Aim: To make a calculator using ATmega16 microcontroller, LCD (16x2) and Keypad (4x4). Note: LCD used in 4 bit mode Code: #define F_CPU 8000000UL #include<avr/io.h> #include<util/delay.h> #include<math.h> void initialize(); void lcd_cmd(char value); void lcd_data(char value); void lcd_string(char *str); void lcd_num(long int number); void keypad(); void operate(); void check(); void special(); long int z=0,i=0,j=0,ar[10],arr[10],far[10],farr[10],op[10],inc=0; void initialize() { lcd_cmd(0x01); //clear LCD lcd_cmd(0x02);    //home position lcd_cmd(0x06);    //L-R //lcd_cmd(0x04); lcd_cmd(0x28); //4 bit mode lcd_cmd(0x0C);    //character generation } void lcd_cmd(char value) { int un,ln; // pc7-pc4 = un ; pc3-pc4 =ln un=value&0xF0; // & is anding function PORTC=0x04|un; _delay_ms(2); PORTC=0x00|un; _delay_ms(2); ln=(value<<4)&0xF0; //<<=left shif by 4 ...