#include #define DIG P0 #define KEY P1sbit LSA=P2^2; sbit LSB=P2^3; sbit LSC=P2^4; unsigned long int count=0, sum=1; int a[11]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x00}; unsigned char KeyDate; unsigned char symbol; void delay(); void KeyDown(); void DigDisplay(); void conversion(); void DigDisplayNumble(); void main(void) { while(1) { KeyDown(); // conversion();// DigDisplay(); } } void KeyDown()// { KEY=0x0f; if(KEY!=0x0f) { delay(); if(KEY!=0x0f) { KEY=0X0F; switch(KEY) { case(0X07): KeyDate=1; break; case(0X0b): KeyDate=2; break; case(0X0d): KeyDate=3; break; case(0X0e): KeyDate=4; break; } KEY=0XF0; switch(KEY) { case(0X70): KeyDate=KeyDate; break; case(0Xb0): KeyDate=KeyDate+4; break; case(0Xd0): KeyDate=KeyDate+8; break; case(0Xe0): KeyDate=KeyDate+12; break; } while(KEY!=0xf0) ; delay(); conversion();// } } } void DigDisplay() { unsigned int j,p=0; for(j=0;j<8;j++) { switch(j) { case(0): LSA=0; LSB=0; LSC=0; DIG=a[count%10]; break; case(1): LSA=1; LSB=0; LSC=0; if(count>=10) DIG=a[count%100/10]; else DIG=a[10]; break; case(2): LSA=0; LSB=1; LSC=0; if(count>=100) DIG=a[count%1000/100]; else DIG=a[10]; break; case(3): LSA=1; LSB=1; LSC=0; if(count>=1000) DIG=a[count%10000/1000]; else DIG=a[10]; break; case(4): LSA=0; LSB=0; LSC=1; if(count>=10000) DIG=a[count%100000/10000]; else DIG=a[10]; break; case(5): LSA=1; LSB=0; LSC=1; if(count>=100000) DIG=a[count%1000000/100000]; else DIG=a[10]; break; case(6): LSA=0; LSB=1; LSC=1; if(count>=1000000) DIG=a[count%10000000/1000000]; else DIG=a[10]; break; case(7): LSA=1; LSB=1; LSC=1; if(count>=10000000) DIG=a[count%100000000/10000000]; else DIG=a[10]; break; } p=10; while(p--); DIG=0x00; } } void conversion() { unsigned keydate_count; if(KeyDate%4!=0) { if(KeyDate!=15)// { switch(KeyDate)// { case 1: case 2: case 3:keydate_count=KeyDate;break; case 5: case 6: case 7:keydate_count=KeyDate-1;break; case 9: case 10: case 11: keydate_count=KeyDate-2;break; case 14 :keydate_count=0;break;
上一篇:基于单片机的负离子空气净化系统设计
下一篇:基于单片机的简易电子琴设计
推荐阅读最新更新时间:2024-11-09 11:24