八路抢答器电子线路设计(附C语言程序)

电子系统课程设计

delay(8);

if((key6 == 0)&&(!key6_flag)) {

key6_flag = 1;

number = 6; number_display = number; } } else {

key6_flag = 0; number = 0; }

if(key7 == 0) {

delay(8);

if((key7 == 0)&&(!key7_flag)) {

key7_flag = 1;

number = 7; number_display = number; } } else {

key7_flag = 0;

number = 0; }

if(key8 == 0)

20

电子系统课程设计

{

delay(8);

if((key8 == 0)&&(!key8_flag))

{

key8_flag = 1;

number = 8; number_display = number; }

}

else

{

key8_flag = 0;

number = 0;

}

if(number_display != 0) {

return 1; } else {

return 0; } }

//复位键扫描函数 void reset_keyscan() {

if(reset == 0) {

21

电子系统课程设计

delay(8);

if((reset == 0)&&( !reset_flag)) {

reset_flag = 1; number_display = 0; state = 1; } } else {

reset_flag = 0; } } //主函数 void main() {

uint t;

TMOD=0x01;

TH0=(65536-50000)/256; TL0=(65536-50000)%6; EA= 1; ET0= 1; TR0=0; while( 1) {

if(number_display!=0)

Play(number_display/2);

start_stop_keyscan();

22

//蜂鸣器发声

电子系统课程设计

reset_keyscan();

while(action) {

while(!key_scan8())

{

display(number_display,second); if(second == 0) {

second = 20; break; } } TR0 = 0;

display(number_display,second); action = 0; break; }

display(number_display,second); } }

//中断服务函数

void timer0() interrupt 1 {

uint i;

TH0=(65536-50000)/256; TL0=(65536-50000)%6;

timer0_count ++; if(timer0_count == 20)

23

联系客服:779662525#qq.com(#替换为@)