|
发表于 2013-5-16 23:21:02
|
显示全部楼层
- #define led_dat_len 3
- uc data led_dat[led_dat_len];
- uc code led_seg[]={
- 0x05,0x7D,0x46,0x54,0x3C,0x94,0x84,0x5D,0x04,0x14,0x0C,0xA4,0x87,0x64,0x86,0x8E};
- void kd_scan()
- {
- H0=H1=H2=H3=0;//¹ØÊýÂë¹ÜËùÓÐλѡ
- P1=0xff;HA=0;//Êý¾Ý¿Úתµ½ÊäÈë״̬
- seg_mask<<=1;if(seg_mask==0){seg_mask=1;}//Éú³ÉÑ»·×óÒÆÑÚÂë
- XD0=P1;HA=1;//¶ÁIO״̬
- if(kd_cnt>=led_dat_len)kd_cnt=0;
- P1=(~seg_mask)|led_seg[led_dat[kd_cnt]];
- if(kd_cnt==0)H0=1;
- if(kd_cnt==1)H1=1;
- if(kd_cnt==2)H2=1;
- if(kd_cnt==3)H3=1;
- kd_cnt++;
- }
复制代码 |
|