基于单片机数码管计分器系统设计-毕业设计资料
1482下载地址 https://docs.qq.com/doc/DWEpnR2pOWU91b3p4?pub=1&dver=2.1.0
#include<reg51.h> #define uchar unsigned char #define uint unsigned int sbit Score_Select=P2^6; sbit Time_Select=P2^7; uchar table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d, 0x7d,0x07,0x7f,0x6f,0x80,0x40,0x00,0x76};//0-9数字,后面为". - 熄灯 H" uchar msec; unsigned char key_down=0;//键按下和松开状态指示,防止重复读取键值 /*****50msec定时器0中断*****/ void T0_int() interrupt 1 { TH0=0x3c; //50ms定时 TL0=0xB0; msec++; } /*****延时子程序*****/ void delay(uint t) { for(;t>0;t--); } /*--------------------------------------------------------*/ /*4*4矩阵键盘键值扫描程序 */ /*返回按键的数字值 */ /*--------------------------------------------------------*/ uchar key_scan(void) { uchar key,key_val; P1=0xf0;//低位行线送低电平 key=P1;//读取高位列线电平 if(key!=0xf0)//是否有键按下 { if(key_down==0)//之前没有按键按下 { key_down=1;//置按键按下标志