Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Sistema de Seguridad - Hex

Descargar como txt, pdf o txt
Descargar como txt, pdf o txt
Está en la página 1de 2

#include <CONTRASEÑA_TECLADO_LCD.

h>

#define LCD_ENABLE_PIN PIN_b0 // ASIGNAMOS EL PIN "B0" COMO SALIDA PARA E


#define LCD_RS_PIN PIN_b1 // ASIGNAMOS EL PIN "B1" COMO SALIDA PARA RS
#define LCD_RW_PIN PIN_b2 // ASIGNAMOS EL PIN "B2" COMO SALIDA PARA RW
#define LCD_DATA4 PIN_b3 // ASIGNAMOS EL PIN "B3" COMO SALIDA PARA D4
#define LCD_DATA5 PIN_b4 // ASIGNAMOS EL PIN "B4" COMO SALIDA PARA D5
#define LCD_DATA6 PIN_b5 // ASIGNAMOS EL PIN "B5" COMO SALIDA PARA D6
#define LCD_DATA7 PIN_b6 // ASIGNAMOS EL PIN "B6" COMO SALIDA PARA D7
#include <lcd.c>

#FUSES NOWDT //No Watch Dog Timer


#FUSES HS //High speed Osc (> 4mhz)
#FUSES PUT //Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOMCLR //Master Clear pin enabled
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18)
used for I/O
#FUSES NOCPD

void main()
{

lcd_init ();
set_tris_d(0x0f);/* se declara el pueto como entrada los promeros 4 pines y
como salida los siguientes 4 pines */
set_tris_b(0x00);
set_tris_c(0x00);
int x[4]={0,0,0,1};/* Pines de salida del puerto D*/
int y[4];/* Pines de entrada del puerto D*/
int z[16];/* Pines de entrada del puerto D*/
int display[16]={7,4,1,0,8,5,2,0,9,6,3,0,0,0,0,0};
int k=0,i=0,j=0,w=1;

while(TRUE)
{
inicio:
output_bit(pin_c0,0);/*salida pin c0*/
w=1;
lcd_gotoxy (1,1);printf(LCD_PUTC," ENTER PASSWORD ");
lcd_gotoxy (1,2);printf(LCD_PUTC," ");
z[1]=0;z[2]=0;z[3]=0;z[4]=0;
teclado:
k=0;
rotate_left(x,4);/* mueve el bit 1 de posición */
output_bit(pin_d4,x[0]);/*salida pin d4*/
output_bit(pin_d5,x[1]);/*salida pin d5*/
output_bit(pin_d6,x[2]);/*salida pin d6*/
output_bit(pin_d7,x[3]);/*salida pin d7*/
y[0]=input(pin_d0);/*entrada pin d0*/
y[1]=input(pin_d1);/*entrada pin d1*/
y[2]=input(pin_d2);/*entrada pin d2*/
y[3]=input(pin_d3);/*entrada pin d3*/

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


{
for(j=0; j<=3; ++j)
{
if (x[i]==1 && y[j]==1)
{
lcd_gotoxy (w,2);printf(LCD_PUTC,"*",);
delay_ms(500);
z[w]=display[k];
w=w+1;
if(z[1]==1 && z[2]==2 && z[3]==3 && z[4]==4 )
{
output_bit(pin_c0,1);/*salida pin c0*/
lcd_gotoxy (1,1);printf(LCD_PUTC," W E L C O M E ");

delay_ms(4000);
goto inicio;
}
if (w==5 && (z[1]!=1 || z[2]!=2 || z[3]!=3 || z[4]!=4) )
{
lcd_gotoxy (1,1);printf(LCD_PUTC," INCORRECT
");
lcd_gotoxy (1,2);printf(LCD_PUTC," PASSWORD
");
delay_ms(2000); goto inicio;

}
goto teclado;
}
k=++k;
}

}
goto teclado;

También podría gustarte