您好,欢迎访问三七文档
当前位置:首页 > 行业资料 > 酒店餐饮 > 项目二数码管时钟显示器
LOGO《单片机技术》一体化课程项目课件课程项目项目名称项目九中文液晶显示器认识单片机项目八带记忆功能的电机控制器项目六数字电压表项目三键盘控制器项目四智能单片机控制器项目五液晶显示器项目七走时精准的定时器项目一花样彩灯项目二数码管时钟显示器项目十温度报警器项目二数码管时钟显示器一我们能学到什么:1.能学到数码管显示方法2.能学到设计数码管显示器的硬件电路3.跟着老师一起能学会实现“时间、日期”显示的数码管数字时钟二我们该怎么做:1.先来学会数码管是怎么显示的abcdegGNDfdpGNDabcefgd·dpabcdefgdpdpgfedcba+5V(a)(b)使用LED显示器时,要注意区分这两种不同的接法。为了显示数字或字符,必须对数字或字符进行编码。七段数码管加上一个小数点,共计8段。因此为LED显示器提供的编码正好是一个字节。TX实验板用共阴LED显示器,根据电路连接图显示16进制数的编码已列在下表。0x3f,0x06,0x5b,0x4f,0x66,0x6d,0123450x7d,0x07,0x7f,0x6f,0x77,0x7c,6789AB0x39,0x5e,0x79,0x71,0x00CDEF无显示。LED数码显示方式及电路静态显示方式LED显示器工作方式有两种:静态显示方式和动态显示方式。静态显示的特点是每个数码管的段选必须接一个8位数据线来保持显示的字形码。当送入一次字形码后,显示字形可一直保持,直到送入新字形码为止。这种方法的优点是占用CPU时间少,显示便于监测和控制。缺点是硬件电路比较复杂,成本较高。动态显示动态显示的特点是将所有位数码管的段选线并联在一起,由位选线控制是哪一位数码管有效。选亮数码管采用动态扫描显示。所谓动态扫描显示即轮流向各位数码管送出字形码和相应的位选,利用发光管的余辉和人眼视觉暂留作用,使人的感觉好像各位数码管同时都在显示。动态显示的亮度比静态显示要差一些,所以在选择限流电阻时应略小于静态显示电路中的。2个显示电路ALEWRRDRXDTXDINT0EA/VP31X119X218RESET9RD17WR16INT012INT113T014T115P101P112P123P134P145P156P167P178P0039P0138P0237P0336P0435P0534P0633P0732P2021P2122P2223P2324P2425P2526P2627P2728PSEN29ALE/P30TXD11RXD10VCC40GND20U189C52PSENP10P11P12P13P14P15P16P17T0T1INT1P00P01P02P03P04P05P06P07P00P01P02P03P04P05P06P07P20P21P22P23P24P25P26P27P20P21P22P23abfcgdeDPY117421105abcdefg3dpdpabfcgdedpabfcgdedpabfcgdedpC06C28C39C412LEDDPY4-LED12345678161514131211109R1KP00P01P02P03P04P05P06P075VK99K10AK15FP10P11P12P13P14P15P16P17EA/VP31X119X218RESET9RD17WR16INT012INT113T014T115P101P112P123P134P145P156P167P178P0039P0138P0237P0336P0435P0534P0633P0732P2021P2122P2223P2324P2425P2526P2627P2728PSEN29ALE/P30TXD11RXD10VCC40GND20U189C52P10P11P12P13P14P15P16P17K00K11K22K33K55K66K77K88K44K11BK12CK13DK14E3.跟着老师一起设计实现“时间、日期”显示的数码管数字时钟步骤:1.硬件仿真电路设计使用Proteus75SP3Setup(单片机仿真软件)a1a8a2a3a4a5a6a7a1a8a2a3a4a5a6a7a1a8a2a3a4a5a6a7b1b8b2b3b4b5b6b7b1b8b2b3b4b5b6b7c8c1c7c6c5c4c3c2c1c8c2c3c4c5c6c7duanweiduanweia1a8a2a3a4a5a6a7XTAL218XTAL119ALE30EA31PSEN29RST9P0.0/AD039P0.1/AD138P0.2/AD237P0.3/AD336P0.4/AD435P0.5/AD534P0.6/AD633P0.7/AD732P1.01P1.12P1.23P1.34P1.45P1.56P1.67P1.78P3.0/RXD10P3.1/TXD11P3.2/INT012P3.3/INT113P3.4/T014P3.7/RD17P3.6/WR16P3.5/T115P2.7/A1528P2.0/A821P2.1/A922P2.2/A1023P2.3/A1124P2.4/A1225P2.5/A1326P2.6/A1427U1AT89C51D03Q02D14Q15D27Q26D38Q39D413Q412D514Q515D617Q616D718Q719OE1LE11U274HC373D03Q02D14Q15D27Q26D38Q39D413Q412D514Q515D617Q616D718Q719OE1LE11U374HC373R110kR210kR310kR410kR510kR610kR710kR810k步骤:2.实现“时间、日期”显示的数码管数字时钟KeiluVision4(单片机编程软件)1.main.c#includereg51.h#includedelay.c#includetime.c#includesmgdis.c#includekey.cvoidmain(){init_time0();while(1){if(shu==0){keyscan();smgdis_sfm(shi,fen,miao);}keyscan();}}2.time.cucharnum,shi,fen,miao;voidinit_time0(){TMOD=0X01;//T0(方式一)TH0=(65535-50000)/256;TL0=(65535-50000)%256;//50000us=50msTR0=1;//启动T1EA=1;//中断总开关ET0=1;//T0分开关}voidtime0()interrupt1{TH0=(65535-50000)/256;TL0=(65535-50000)%256;//50000us=50msnum++;//50msif(num==20)//1s{num=0;miao++;if(miao==60){miao=0;fen++;if(fen==60){fen=0;shi++;if(shi==24){shi=0;}}}}}3.smg.cucharcodetable1[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xbf,0xff};ucharcodetable2[]={0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};sbitduan=P1^0;sbitwei=P1^1;voidsmgdis1(ucharadd,uchardate)//任意位置(add)显示任意数据(date){P0=table2[add];wei=1;wei=0;P0=table1[date];duan=1;duan=0;delay(5);}voidsmgdis_miao(ucharmiao){ucharm1,m2;//其中m1表示秒的个位m2表示秒的十位m1=miao/10;m2=miao%10;smgdis1(2,m1);smgdis1(1,m2);voidsmgdis_sfm(uchars,ucharf,ucharm){uchars1,s2,f1,f2,m1,m2;s1=s/10;s2=s%10;f1=f/10;f2=f%10;m1=m/10;m2=m%10;smgdis1(8,s1);smgdis1(7,s2);smgdis1(6,10);smgdis1(5,f1);smgdis1(4,f2);smgdis1(3,10);smgdis1(2,m1);smgdis1(1,m2);}voidsmg_san(ucharclock){uchars1,s2,f1,f2,m1,m2;s1=shi/10;s2=shi%10;f1=fen/10;f2=fen%10;m1=miao/10;m2=miao%10;if(clock==1)//闪秒{smgdis1(8,s1);smgdis1(7,s2);smgdis1(6,10);smgdis1(5,f1);smgdis1(4,f2);smgdis1(3,10);smgdis1(2,11);smgdis1(1,11);}if(clock==2)//闪分{smgdis1(8,s1);smgdis1(7,s2);smgdis1(6,10);smgdis1(5,11);smgdis1(4,11);smgdis1(3,10);smgdis1(2,m1);smgdis1(1,m2);}if(clock==3)//闪时{smgdis1(8,11);smgdis1(7,11);smgdis1(6,10);smgdis1(5,f1);smgdis1(4,f2);smgdis1(3,10);smgdis1(2,m1);smgdis1(1,m2);}}4.key.csbitk1=P3^3;sbitk2=P3^2;sbitk3=P3^5;sbitk4=P3^4;signedcharmov,shu,up,down;voidclock_mov(ucharmov){ucharaa=20,bb=20;if(mov==1){while(aa--){smgdis_sfm(shi,fen,miao);if((k1==0)||(k2==0)||(k3==0)||(k4==0))break;}while(bb--){smg_san(1);if((k1==0)||(k2==0)||(k3==0)||(k4==0))break;}}if(mov==2){while(aa--){smgdis_sfm(shi,fen,miao);if((k1==0)||(k2==0)||(k3==0)||(k4==0))break;}while(bb--){smg_san(2);if((k1==0)||(k2==0)||(k3==0)||(k4==0))break;}}if(mov==3){while(aa--){smgdis_sfm(shi,fen,miao);if((k1==0)||(k2==0)||(k3==0)||(k4==0))break;}while(bb--){smg_san(3);if((k1==0)||(k2==0)||(k3==0)||(k4==0))break;}}if(mov==4)mov=0;}voidclock_up(ucharup){if(up==1){if(k2==0){delay(5);if(k2==0){{while(aa--){smgdis_sfm(shi,fen,miao);if((k1==0)||(k2=
本文标题:项目二数码管时钟显示器
链接地址:https://www.777doc.com/doc-1961849 .html