电子系统课程设计
P2 = 0xf7;
P0 = table[second_second]; delay(2); }
//蜂鸣器响应按周期t发音 void Play(uchar t) { }
//开始键扫描函数
void start_stop_keyscan() {
if(start_stop == 0) {
delay(8);
if((start_stop == 0)&&(!start_stop_flag))
{
uchar i; for(i=0;i<1;i++) { } BEEP=0;
BEEP=~BEEP; DelayMS(t); P0 =0x00;
start_stop_flag = 1; action = 1; TR0 = 1; state = 0; }
16
电子系统课程设计
} else {
start_stop_flag = 0; } }
//八位抢答键扫描函数 uchar key_scan8() {
if(key1 == 0) {
delay(8);
if((key1 == 0)&&(!key1_flag)) {
key1_flag = 1;
number = 1; number_display = number;
}
}
else {
key1_flag = 0;
number = 0; }
if(key2 == 0) {
delay(8);
if((key2 == 0)&&(!key2_flag)) {
17
电子系统课程设计
key2_flag = 1;
number = 2; number_display = number; } } else {
key2_flag = 0;
number = 0; }
if(key3 == 0) {
delay(8);
if((key3 == 0)&&(!key3_flag)) {
key3_flag = 1;
number = 3; number_display = number;
} } else {
key3_flag = 0;
number = 0; }
if(key4 == 0) {
delay(8);
18
电子系统课程设计
if((key4 == 0)&&(!key4_flag)) {
key4_flag = 1;
number = 4; number_display = number; } } else {
key4_flag = 0;
number = 0; }
if(key5 == 0) {
delay(8);
if((key5 == 0)&&(!key5_flag)) {
key5_flag = 1;
number = 5; number_display = number; }
} else {
key5_flag = 0;
number = 0; }
if(key6 == 0) {
19