版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
防抖动#include<reg5l.h>sbit key二Pl八〇;unsigned char codetable[]={Ox3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,Ox7f,0x6f};voiddelay(intms){unsignedchari;while(ms—)for(i=0;ivl20;i++);}main(){unsignedchari=0;P3=table[0];while(l)if(key==O)delay(10);if(key==0)i++;if(i>=10)i=0;})while(key!=l);delay(lO);P3=table[i];P2=table[i+1];}
按键处理#include<reg5l.h>#include<intrins.h>sbitkeyl=PlA0;sbitkey2=PlAl;sbitkey3=P1A2;unsigned char codetable[]={0x81,0x42,0x44,Ox18,0xfc,0xf9,0xf3,0xe7,0xcf,0x9f,0x3f,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe7,0xdb,0xbd,0x7e,0xbd,0xdb,0xe7,0xff,0xe7,0xc3,0x81,0x00,0x81,0xc3,0xe7,0xff,Oxaa,0x55,0x18,0xff,0xf0,0x0f,0x00,0xff,0xf8,Oxfl,0xe3,0xc7,0x8f,0x1f,0x3f,0x7f,0x7f,0x3f,0xlf,0x8f,0xc7,0xe3,Oxfl,0xf8,0xff,0x00,Ox00,0xff,0xff,0x0f,0xf0,0xff,0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00,0x00,0x00,0xOO,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0x00,Oxff,0x00,Oxff,0x00,Oxff,0x00,Oxff,Oxff,Oxff,Oxff,0xff,0xff,0xff,0xff,0xfe,0xfc,0xf9,0xf3,0xe7,0xcf,0x9f,0x3f,0xff,0xe7,0xdb,0xbd,0x7e,0xbd,0xdb,0xe7,0xff,0xe7,0xc3,0x81,0x00,0x8l,0xc3,0xe7,0xff,Oxaa,0x55,0x18,Oxff,OxfO,OxOf,0x00,0xff,0xf8,Oxfl,0xe3,0xc7,0x8f,0x1f,0x3f,0x7f,0x7f,0x3f,0xlf,0x8f,0xc7,0xe3,Oxfl,0xf8,0xff,0x00,Ox00,0xff,0xff,0x0f,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0xfd,0xfb,0xf7,Oxef,Oxdf,Oxbf,0x7f,0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00,0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,Oxff,0x00,Oxff,0x00,Oxff,0x00,0xf0};voiddelay(unsignedcharms)(unsignedchari;while(ms—)for(i=0;i<120;i++);)voidmain(){inti;charLED;LED=0xfe;P2=0x01;P3=0x01;P0=0x01;while(l)(if(keyl==O){for(i=0;i<276;i++){P2=table[i];delay(255);)}if(key2==0)(for(i=0;i<10;i++)(P3=0xff;delay(235);P3=OxOO;delay(255);if(key3==0)(for(i=0;i<8;i++)(POLLED;delay(250);LED=_crol_(LED,l);)if(key3==l)(for(i=0;i<8;i++){PO二LED;LED=_cror_(LED,l);delay(25O);KeiQ1234567ra&aP1P1P1P1P1P1P1P1P0.3ACBpzofiepzaffiao流水灯#include<reg5l.h>voiddelay(intms){inti,j;for(i=ms;i>0;i—)for(j=0;j<120;j++);}unsignedcharled1[]={0x81,0x42,0x44,Ox18};unsignedcharled2[]={Ox18,0x24,0x44,0x81};voidmain(){inti,j;while(l){for(i=0;i<4;i++)for(j=0;j<4;j++){P2=ledl[i];P3=led2[j];delay(250);{ for(i=0;i<4;i++)P2=0xff;delay(250);P2=0x00;delay(250);}}}}流水灯#include<reg5l.h>voiddelay(intms){inti,j;for(i=ms;i>0;i—)for(j=0;j<120;j++);)unsignedchartable[]={0x7e,0xbd,0xdb,0xe7};voidmain(){intk;while(l){for(k=0;k<4;k++){P2=table[k];delay(240);{ for(k=0;k<4;k++)30S8PQV/dTpvsnro3w^naPOSロRl&ACB377/07NQ/eP2.5P2JZM0F^aAl-lN4A12P2SAt3P20AKR2.5JAI5303©P3VDO?.'•,争ーPaSWHR14TDP35Tlpas^RRazaV—*{P22XK;
delay。〇。〇);
PKXOO;
delayuo。〇);共阳共阴数码管Textl.c#include<reg5l.h>unsigned char codetable2[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};unsigned char codetablel[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x83,0xf8,0x80,0x98};voiddelay(intms){inti,j;for(i=ms;i>0;i")for(j=0;j<120;j++);)voidmain(){intk;while(l)(for(k=0;k<10;k++)(P2=tablel[k];P3=table2[k];delay(WOO);}}}数码管ATextlg.c#include<reg5l.h>voiddelay(intms)(inti,j;for(i=ms;i>0;i")for(j=0;j<120;j++);)char codetable[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,Ox7f,0x6f};voidmain()(inti,j;while(l)(for(j=0;j<10;j++)P2=table[j];for(i=0;i<10;i++)(Pl=table[i];delay(500);))数码管ATextlg.c#include<reg5l.h>voiddelay(intms){intij;for(i=ms;i>0;i—)for(j=0;j<120;j++);)intledl[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,Ox7f,0x6f};intIed2[]={Ox3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,Ox7f,0x6f};voidmain(){inti,j;while(l)(for(i=0;i<10;i++)for(j=0;j<10;j++)(Pl=ledl[i];P2=led2[j];delay(500);)))数码管的动态显示Text2.c#include<reg5l.h>sbit key二PIN);#include<stdlib.h>unsigned char codetable[l={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x83,Oxf8,Ox80,0x98};unsignedcharbuffer[4];unsignedintn;voiddelay(intms){inti,j;for(i=ms;i>0;i")for(j=0;j<120;j++);}handle(unsignedintn)(unsignedchari;for(i=0;i<4;i++)(buffer[i]=n%10;n=n/10;))voidanjian()if(key==O)delay(10);if(key==0){n++;n=rand()%10000;if(n>9999)n=0;while(key!=l);}))voidxianshiQ(unsignedchari,weixuan;weixuan=0x80;for(i=0;i<4;i++)P2=weixuan;P3=table[buffer[i]];delay⑸;weixuan»=l;})main()n=1234;n=rand()%10000;handle(n);while(l){handle(n);anjian();xianshiQ;2ss2ss3fl中断Textl.c#include<reg5l.h>#include<intrins.h>unsignedcharcodeled[]={0x7e,0xbd,0xdb,0xe7};delay_ms(unsignedcharms)(unsignedchari;while(ms")for(i=0;i<120;i++);)main()unsignedchari;ITO=1;IT1=1;EXO=1;EX1=1;EA=1;while(l)for(i=0;i<3;i++)(PO=led[i];delay_ms(250);)for(i=3;i>0;i-)|PO=led[i];delay_ms(250);))intO()interrupt0(unsignedchari,LED;LED=Oxfe;for(i=0;i<8;i++)(POLLED;delay_ms(250);LED=_crol_(LED,l);))intl()interrupt2(unsignedchari,LED;LED=0x7f;for(i=0;i<8;i++)(POLLED;delay_ms(250);LED=_cror_(LED,l);}豐piね豐piねつ;=i過-f-zfSIH・亠T-T-循环#include<reg5l.h>unsigned char codetable[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,Ox7f,0x6f};delay(unsignedcharms)unsignedchari;while(ms—)for(i=0;i<120;i++);)voidmain()(unsignedchari;T0=l;1,while(l)for(i=0;i<10;i++)(Pl=table[i];delay(500);)i++;if(i=3)while(l)for(i=10;i>0;i—)(Pl=table[i];delay(500);}}}))循环#include<reg5l.h>unsigned char codetable[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,Ox7f,0x6f};delay(unsignedcharms)(unsignedchari;while(ms—)for(i=0;i<120;i++);)voidmain()unsignedchari,j;for(j=0;j<3;j++)for(i=0;i<10;i++)(Pl=table[i];delay(lOOO);)for(i=10;i>0;i—)(Pl=table[i];delay(lOOO);)while(l);}内部中断Textl.c#include<reg5l.h>unsigned char codetable[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,Ox7f,0x6f};delay(unsignedcharms)unsignedchari;while(ms—)for(i=0;i<120;i++);)voidmain()(unsignedchari,j;P2=table[0];T0=l;EX0=l;EA=1;for(j=0;j<3;j++)for(i=0;ivl0;i++)Pl=table[i];delay(250);))while(l);)intO()interrupt0(unsignedchari;for(i=10;i>0;i-)(Pl=table[i];delay(250);UIXUM.1XTfiLZRSTALE.序P1P1P1P1P1P1P1P1FQ(y/>CDFU1/AD1P02/AC2RI3m3FQ4/ZAPDL560C6PQ&ADBFQ77ZM37P2.OABP2.1/fiGP23A10P23A11P24/A12P25Al3P2.&M4P277A15RIOR©pai/noR12T4TDP3»WHR14TOpasnR36Y妃P3.7/FDzizi過メ嚏zi-i-噎zz逢過達红绿灯#include<reg5l.h>#defineucharunsignedchar#defineuintunsignedintsbitRED_A二PO八〇;〃东西向灯sbitYELLOW_A=POA1;sbitGREEN_A二POハ2;sbitRED_B二POハ3;〃南北向灯sbitYELLOW_B二POハ4;sbitGREEN_B=P0A5;voiddelay(unsignedintms)(unsignedchari;while(ms—)for(i=0;i<120;i++);)voidmain(){unsignedchari;RED_A=0;GREEN_B=0;delay(10000);GREEN_B=1;delay(500);(for(i=0;i<5;i++){YELLOW_A=OXFE;YELLOW_B=0XEF;delay(250);YELLOW_B=OXOO;delay(250);YELLOW_B=1;}RED_A=1;delay(500);RED_B=0;GREEN_A=0;delay(10000);GREEN_A=1;delay(500);}for(i=0;i<5;i++)(YELLOW_B=OXFF;YELLOW_A=OXFF;delay(250);YELLOW_A=OXOO;delay(250);YELLOW_A=1;)RED_B=1;delay(500);红绿灯#include<reg5l.h>#defineucharunsignedchar#defineuintunsignedintsbitRED_A=PO八〇;〃东西向灯sbitYELLOW_A=POA1;sbitGREEN_A二POハ2;sbitRED_B=P0ハ3;〃南北向灯sbitYELLOW_B二POハ4;sbitGREEN_B=P0A5;unsignedcharj=0;bitflag;voiddelay(unsignedintms)(unsignedchari;while(ms—)for(i=0;i<120;i++);)voidmain(){unsignedchari;TMOD=0X01;TH0=(65536-50000)/256;TL0=(65536-50000)%256;EA=1;ETO=1;TRO=1;while(l)(if(flag==l)(RED_A=0;GREEN_B=0;delay(10000);GREEN_B=1;delay(0);(for(i=0;i<5;i++)|YELLOW_A=OXEE;YELLOW_B=OXFE;delay(250);YELLOW_B=OXOO;delay(250);YELLOW_B=1;}RED_A=1;delay(0);RED_B=0;GREEN_A=0;delay(10000);GREEN_A=1;delay(0);)for(i=0;i<5;i++)(YELLOW_B=OXFF;YELLOW_A=OXFF;delay(250);YELLOW_A=OXOO;delay(250);YELLOW_A=1;)RED_B=1;delay(0);)}flag=0;)voidintl()interrupt1TH0=(65536-50000)/256;TL0=(65536-50000)%256;j++;if(j==20)(j=。;flag=l;))#include<reg5l.h>#defineucharunsignedchar#defineuintunsignedintsbitRED_A=PO八〇;〃东西向灯sbitYELLOW_A二PON;sbitGREEN_A二P。ハ2;sbitRED_B二PO八3;〃南北向灯sbitYELLOW_B=POA4;sbitGREEN_B=P0A5;unsignedcharj=O;voiddelay(unsignedintms)unsignedchari;while(ms—)for(i=0;i<120;i++);)voidmain()(TMOD=OXOl;TH0=(65536-50000)/256;TL0=(65536-50000)%256;EA=1;ETO=1;TR0=1;while(l);voidintl()interrupt1{unsignedchari;TH0=(65536-50000)/256;TL0=(65536-50000)%256;j++;if(j=20)(j=0;RED_A=O;GREEN_B=0;delay(10000);GREEN_B=1;delay(0);(for(i=0;i<5;i++)(YELLOW_A=OXFF;YELLOW_B=OXEF;delay(250);YELLOW_B=OXOO;delay(250);YELLOW_B=1;RED_A=1;delay(0);RED_B=0;GREEN_A=0;delay(10000);GREEN_A=1;delay(0);)for(i=0;i<5;i++)(YELLOW_B=OXFF;YELLOW_A=OXFF;delay(250);YELLOW_A=OXOO;delay(250);YELLOW_A=1;}RED_B=1;delay(0);XVA12f=孤±圭±±ALE孫P2LO-A8P2.VPQpaaAioP23AMR24A12Pa&A13P28A14P2.77A15paoR©Riim©paawroR13WT1P3.4T0R3.5TIR16AAA可调手隼园所#incIude<reg51.h>unsignedchar尸〇,k二〇;unsignedintN,Y,R,S,F,M;sbitkey1=P3'0;sbitkey2=P31;bitflag;unsignedcharcodetab[]={OxcO,Oxf9,0xa4,OxbO,0x99,0x92,0x83,Oxf8,0x80,0x98};unsigned intbuffer[4],buffer1[2],buffer2[2],buffer3[2],buffer4[2],buffer5[2];voiddeIay(unsignedintms){unsignedcharj;while(ms一);for(j=0;j<120;j++);)handIe(unsignedintN)(unsignedchari;for(i=0;i<4;i++)(buffer[i]=N%10;N=N/10;}}handIe1(unsignedintY)unsignedchari;for(i=0;i<2;i++)(bufferl[i]=Y%10;Y=Y/10;}handIe2(unsignedintR)unsignedchari;for(i=0;i<2;i++)(buffer2[i]=R%10;R=R/10;}handIe3(unsignedintS)unsignedchari;for(i=0;i<2;i++)buffer3[i]=S%10;S=S/10;))handIe4(unsignedintF)(unsignedchari;for(i=0;i<2;i++)(buffer4[i]=F%10;F=F/10;1}handIe5(unsignedintM)(unsignedchari;for(i=0;i<2;i++)(buffer5[i]=M%10;M=M/10;})voidxianshi()unsignedchari,weixuan;weixuan=0x08;for(i=0;i<4;i++)(P0=weixuan;P1=tab[buffer[i]];delay(5);weixuan»=1;})voidxianshi1()(unsignedchari,weixuan;weixuan=0x20;for(i=0;i<2;i++)(P0=weixuan;P1=tab[buffer1[i]];delay(5);weixuan»=1;)}voidxianshi2()unsignedchari,weixuan;weixuan=0x80;for(i=0;iく2;i++)(P0=weixuan;P1=tab[buffer2[i]];deIay(5);weixuan»=1;))voidxianshi3()(unsignedchari,weixuan;weixuan=0x08;for(i=0;i<2;i++)(P3=weixuan;P2=tab[buffer3[i]];deIay(5);weixuan»=1;})voidxianshi4()(unsignedchari,weixuan;weixuan=0x20;for(i=0;i<2;i++)(P3=weixuan;P2=tab[buffer4[i]];delay(5);weixuan»=1;))voidxianshi5()(unsignedchari,weixuan;weixuan=0x80;for(i=0;i<2;i++)P3=weixuan;P2=tab[buffer5[i]];deIay(5);weixuan»=1;))voidjinzhi()if(M<60){M++;if(M==60){
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
评论
0/150
提交评论