赞
踩
《单片机六路抢答器C语言程序》由会员分享,可在线阅读,更多相关《单片机六路抢答器C语言程序(4页珍藏版)》请在人人文库网上搜索。
1、单片机六路数显计时抢答器c语言程序#include #define uint unsigned int#define uchar unsigned charunsigned char code table=0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xc0;sbit start=P36;sbit reset=P37;sbit key1=P10;sbit key2=P11;sbit key3=P12;sbit key4=P13;sbit key5=P14;sbit key6=P15;sbit key7=P16;sbit key8=P17;。
2、sbit jia=P34;sbit jian=P35;bit action = 0;uchar second=10,a7=0;uchar timer0_count = 0;uchar number=0;uchar number_display = 0;uchar k;void delay(uint z)uint x,y;for(x=z;x0;x-)for(y=120;y0;y-);void display(uchar number,uchar second)P2 = 0x01;P0 = tablesecond;delay(1);P2 = 0x02;P0 = tablenumber;delay(。
3、1);P2 = 0x04;P0 = tablea0;delay(1);P2 = 0x08;P0 = tablea1;delay(1);P2 = 0x10;P0 = tablea2;delay(1);P2 = 0x20;P0 = tablea3;delay(1);P2 = 0x40;P0 = tablea4;delay(1);P2 = 0x80;P0 = tablea5;delay(1);void start_keyscan()void fengling();while(start = 0)key7=0;display(number_display,second);if(start = 1)ke。
4、y7=1;action = 1;TR0 = 1;uchar key_scan8()if(key1 = 0)delay(8);if(key1 = 0)number = 1;number_display = number;if(key2 = 0)delay(8);if(key2 = 0)number = 2;number_display = number;if(key3 = 0)delay(8);if(key3 = 0)number = 3;number_display = number;if(key4 = 0)delay(8);if(key4 = 0)number = 4;number_disp。
5、lay = number;if(key5 = 0)delay(8);if(key5 = 0)number = 5;number_display = number;if(key6 = 0)delay(8);if(key6 = 0)number = 6;number_display = number;if(number_display != 0)return number_display;elsereturn 0;void reset_keyscan()if(reset = 0)delay(8);if(reset = 0)number_display = 0;second=10;void main。
6、()TMOD=0x01;TH0=(65536-50000)/256;TL0=(65536-50000)%256;EA=1;ET0=1;TR0=0;P2=0x00;while(1)reset_keyscan();start_keyscan(); if(jia=0&anumber-10)delay(10);while (jian=0)display(number_display,second);anumber-1=anumber-1-1;while(action)while(!key_scan8() display(number_display,second);if(second = 0)second = 10;break;TR0 = 0;key7=0;delay(80);display(number_display,second);key7=1;action = 0;break;display(number_display,second); void timer0() interrupt 1TH0=(65536-50000)/256;TL0=(65536-50000)%256;timer0_count +;if(timer0_count = 20)second -;timer0_count = 0;if(second=0)key7=0;delay(60);key7=1。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。