【文件属性】:
文件名称:基于51单片机的密码锁
文件大小:13KB
文件格式:UVPROJ
更新时间:2018-02-16 15:40:06
密码锁
基于8051单片机的密码锁的c语言代码
#include
typedef unsigned char uchar;
typedef unsigned int uint;
//¼üÅÌ×Ó³ÌÐòÏà¹Ø˵Ã÷
#define BLANKCHAR 10 //¶¨Òå¿Õ°×³£Á¿
#define PCHAR 11 //¶¨Òå×Ö·û P ³£Á¿(µÈ´ýÓû§ÊäÈëÃÜÂë)
#define OPENCHAR 12 //¶¨Ò忪Ëø×Ö·û |¡ª ³£Á¿
#define ALARMCHAR 13 //¶¨Òå×Ö·û A ³£Á¿£¨ÃÜÂë¶à´Î´íÎ󾯸棩
#define LINECHAR 14 //¶¨Òå×Ö·û - ³£Á¿
#define BACKKEY 0X0D //¶¨ÒåÍ˸ñ°´¼ü³£Á¿
#define ENTERKEY 0X0F //¶¨ÒåÈ·Èϼü³£Á¿
#define LOCKKEY 0X0E //¶¨Òå±ÕËø¼ü³£Á¿
#define NO_KEY 20 //¶¨ÒåÎÞ°´¼ü·µ»ØÖµ
//¶¨Òå°´¼üɨÃèÂë±í£¬°´¼üɨÃèʱ£¬4λÁÐÏߺÍ4λÐÐÏß×é³É×Ö½ÚÊý¾Ý±í
uchar code KEYCODE[] = {0XEE,0XDE,0XBE,0X7E, // 0 1 2 3
0XED,0XDD,0XBD,0X7D, // 4 5 6 7
0XEB,0XDB,0XBB,0X7B, // 8 9
0XE7,0XD7,0XB7,0X77};// back lockkey enter
uchar KeyPre; //±£´æÉÏ´ÎɨÃè°´¼üµÄ¼üÖµ
uchar KeyUp;//ÓÃÓÚ¿ØÖÆ°´¼üÈ¥¶¶¶¯²Ù×÷¡£1£ºÉ¨ÃèʱÏû¶¶ 2£ºµÈ´ýÊÍ·Å 3£ºÊÍ·ÅʱÏû¶¶
#define LEDPORT P0 //¶¨ÒåÏÔʾÆ÷¶ÎÂëÊä³ö¶Ë¿Ú
#define LEDCON P1 //¶¨ÒåÏÔʾÆ÷λ¿ØÖƶ˿Ú
#define KEYPORT P2 //¶¨Òå¼üÅ̶˿Ú
sbit ALARMCON = P3^3; //¶¨Ò屨¾¯¿ØÖÆÒý½Å
sbit LOCKCON = P3^5; //¶¨Òåµç×ÓËø¿ØÖÆÒý½Å
uchar code SEGCODE[] =
{0XC0,0XF9,0XA4,0XB0,0X99,0X92,0X82,0XF8,0X80,0X90,//0...9µÄ¹²Ñô¼«¶ÎÂë
0XFF,//²»ÏÔʾ
0X8C,//ÏÔʾ×Ö·ûP(µÈ´ýÓû§ÊäÈëÃÜÂë)
0X8F,//|-µÄ¹²Ñô¼«¶ÎÂ루¿ªËø£©
0X88,//×Ö·ûA
0XBF,//×Ö·û-
0X9f,//·µ»Ø×Ö·û
};