常用程序_免费下载.doc_第1页
常用程序_免费下载.doc_第2页
常用程序_免费下载.doc_第3页
常用程序_免费下载.doc_第4页
常用程序_免费下载.doc_第5页
已阅读5页,还剩10页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

大键盘#include#define uchar unsigned char#define uint unsigned intsbit dula=P26;sbit wela=P27;uchar code table=0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71;void delay(uint x)uint i,j;for(i=x;i0;i-)for(j=100;j0;j-);void display(uchar num)P0=tablenum;dula=1;dula=0;void matrixkeyscan()uchar temp,key;P3=0xfe;temp=P3;temp=temp&0xf0;if(temp!=0xf0)delay(10);temp=P3;temp=temp&0xf0;if(temp!=0xf0)temp=P3;switch(temp)case 0xee:key=0;break;case 0xde:key=1;break;case 0xbe:key=2;break;case 0x7e:key=3;break;while(temp!=0xf0)temp=P3;temp=temp&0xf0;display(key);void main()P0=0;dula=1;dula=0;wela=1;P0=0x00;wela=0;while(1)matrixkeyscan();流水灯#include#define uchar unsigned char#define uint unsigned intsbit dula=P26;sbit wela=P27;uchar num;void delay(uint);uchar code table=0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71;void delay(uint x)uint i,j;for(i=x;i0;i-)for(j=110;j0;j-);void main()while(1)dula=1;P0=table1;dula=0;P0=0xff;wela=1;P0=0xfe;wela=0;delay(500);dula=1;P0=table2;dula=0;P0=0xff;wela=1;P0=0xfd;wela=0;delay(500);dula=1;P0=table3;dula=0;P0=0xff;wela=1;P0=0xfb;wela=0;delay(500);dula=1;P0=table4;dula=0;P0=0xff;wela=1;P0=0xf7;wela=0;delay(500);dula=1;P0=table5;dula=0;P0=0xff;wela=1;P0=0xef;wela=0;delay(500);dula=1;P0=table6;dula=0;P0=0xff;wela=1;P0=0xdf;wela=0;delay(500);共阳极数字编码uchar code table=0xc0,0xf9,0xa4,0xb0, 0x99,0x92,0x82,0xf8, 0x80,0x90,0x88,0x83, 0xc6,0xa1,0x86,0x8e;共阴极uchar code table=0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71;延时程序msvoid delay(uint x)uint i,j;for(i=x;i0;i-)for(j=110;j0;j-);四个键盘检测#include#define uchar unsigned char#define uint unsigned intsbit dula=P26;sbit wela=P27;sbit key1=P34;sbit key2=P35;sbit key3=P36;sbit key4=P37;uchar numt0,num;void delay(uint);uchar code table=0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71;void delay(uint x)uint i,j;for(i=x;i0;i-)for(j=110;j0;j-);void display(uchar numdis)uchar shi,ge;shi=numdis/10;ge=numdis%10;dula=1;P0=tableshi;dula=0;P0=0xff;wela=1;P0=0xfd;wela=0;delay(5);dula=1;P0=tablege;dula=0;P0=0xff;wela=1;P0=0xfe;wela=0;delay(5);void init()TMOD=0X01;TH0=(65536-45872)/256;TL0=(65536-45872)%256;EA=1;ET0=1;void keyscan()if(key1=0)delay(10);if(key1=0)num+;if(num=60)num=0;while(!key1);if(key2=0)delay(10);if(key2=0)if(num=00)num=60;num-;while(!key2);if(key3=0)delay(10);if(key3=0)num=0;while(!key1);if(key4=0)delay(10);if(key4=0)while(!key1);TR0=TR0;void main()init();while(1)keyscan();display(num);void T0_time() interrupt 1TH0=(65536-45872)/256;TL0=(65536-45872)%256;numt0+;if(numt0=20)numt0=0;num+;if(num=60)num=0;数码管全亮,依次显示0到F,时间间隔1秒#include#define uchar unsigned char#define uint unsigned intuchar a;sbit wei1=P10;sbit wei2=P11;sbit wei3=P12;sbit wei4=P13;uchar code table=0xc0,0xf9,0xa4,0xb0, 0x99,0x92,0x82,0xf8, 0x80,0x90,0x88,0x83, 0xc6,0xa1,0x86,0x8e;void delay(uint);void main()wei1=0;wei2=0;wei3=0;wei4=0;while(1)for(a=0;a0;i-)for(j=110;j0;j-);#include#include#defined uint unsigned int#defined uchar unsigned charuchar temp,aa,num;void delay(uint);uchar code table=0xc0,0xf9,0xa4,0xb0, 0x99,0x92,0x82,0xf8, 0x80,0x90,0x88,0x83, 0xc6,0xa1,0x86,0x8e;void main()TMOD=0X01;THO=(65536-50000)/256;TLO=(65536-50000)%256;EA=1;ET0=1;TR0=1;temp=0xfe;while(1)P0=temp;temp=_crol_(temp,1);delay(1000);void delay(uint z)uint i,j;for(i=z;i0;i-)for(j=110;j0;j-);void tempter() interrupt 1THO=(65536-50000)/256;TLO=(65536-50000)%256;aa+;if(aa=40)aa=0;P1=0x00;P0=table=num;num+;if(num=16)num=0;付账号: 6217 0001 1000 2614 2479052#include#define uchar unsigned char#define uint unsigned intsbit key1=P20;sbit key2=P21;sbit key3=P22;sbit key4=P23;sbit shi1=P10;sbit ge1=P11;uchar code table=0xc0,0xf9,0xa4,0xb0, 0x99,0x92,0x82,0xf8, 0x80,0x90,0x88,0x83, 0xc6,0xa1,0x86,0x8e;void delay(uint);uchar num0;num,aa;void display(uchar num1)uchar shi,ge;shi=num1/10;ge=num1%10;shi1=1;P0=tableshi;delay(5);shi1=0;ge1=1;P0=tablege;delay(50);ge1=0; void delay(uint x)uint i,j;for(i=x;i0;i-)for(j=110;j0;j-);/*void init()TMOD=0x01;TH0=(65536-50000)/256;TL0=(65536-50000)%256;EA=1;ET0=1;*/void keyscon()if(key1=0)delay(10);if(key1=0)num+;if(num60)num=0;while(!key1);if(key2=0)delay(10);if(key2=0)if(num=0)num=60;num-;while(!key2);if(key3=0)delay(10);if(key3=0)num=0;while(!key3);if(key4=0)delay(10);if(key4=0)while(!key4);TR0=TR0; void main()TMOD=0x01;TH0=(65536-50000)/256;TL0=(65536-50000)%256;EA=1;ET0=1;/init();while(1)keyscon();display(num);void TO_time() interrupt 1TH0=(65536-50000)/256;TL0=(65536-50000)%256;aa+;if(aa=20) aa=0;num+;if(num=60)num=0;数码管使用#include#define uchar unsigned char#define uint unsigned intsbit dula=P26;sbit wela=P27;uchar num;void delay(uint);uchar co

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论