《按键控制数码管显示数字加减(共3页).doc》由会员分享,可在线阅读,更多相关《按键控制数码管显示数字加减(共3页).doc(3页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、精选优质文档-倾情为你奉上#include#define uchar unsigned char #define uint unsigned intuint num=0,num1=0;sbit key1=P30;sbit key2=P31;sbit key3=P32;sbit key4=P33;uchar table=0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f;void delayms(uint x) uint i,j; for(i=x;i0;i-) for(j=110;j0;j-);void display(uint num) uint
2、 shi,ge; shi=num/10; ge=num%10; P0=tableshi; P1=0xfd; delayms(5);P0=tablege; P1=0xfe; delayms(5);void keyscan() if(key1=0) delayms(10); if(key1=0) num1+; if(num1=60) num1=0; while(!key1) display(num1); if(key2=0) delayms(10); if(key2=0) if(num1=0) num1=60; num1-; while(!key2)display(num1); if(key3=0
3、) delayms(10); if(key3=0) num1=0; while(!key3)display(num1); if(key4=0) delayms(10); if(key4=0) TR0=TR0;while(!key4)display(num1); void main() TMOD=0x01; TH0=(65536-45872)/256; TL0=(65536-45872)%256; EA=1; ET0=1; while(1) keyscan(); display(num1); void T()interrupt 1 TH0=(65536-45872)/256; TL0=(65536-45872)%256; num+; if(num=20) num1+; num=0; if(num1=60) num1=0;专心-专注-专业