#include <reg51.h>
//#include <keyscan.h>
//#include <display.h>
#define uchar unsigned char
#define uint unsigned int
sbit kai = P1^7; //定义开始抢答按键
sbit ting = P1^6; //定义停止答题按键
sbit wei1 = P2^0; // 定义位选1
sbit wei2 = P2^1; // 定义位选2
sbit wei3 = P2^2; // 定义位选3
sbit wei4 = P2^3; // 定义位选4
sbit P37 = P3^7; //定义抢答开始
sbit P36 = P3^6; //定义复位按键
sbit P25 = P2^5; //定义蜂鸣器
uchar code table[] = {0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f, 0x40};
uchar a, a1, num, shi, ge, hao,
num1, flag1, flag2, flag3, flag4,
flag5, flag6, flag7, flag8, flag9, flag1, temp;
void display(uchar hao, uchar aa, uchar shi, uchar ge);
void init();
void delay(uint z);
void keyscan();
void init()
{
TMOD = 0x11; //定义定时器工作方式;定时器1的方式1,定时器0的方式0
TH0 = (65536 - 50000) / 256; //装初值
TL0 = (65536 - 50000) % 256;
EA = 1; //开总中断
ET0 = 1; //开
|