您的位置 首页 汽车

一个好玩的C51动态扫描小程序

初学者上手的简单程序,把下面代码复制进keil代码窗口,烧进51hei开发板,看看结果吧includereg52h>defineucharunsignedchardef

初学者上手的简略程序,把下面代码仿制进keil代码窗口,烧进51hei开发板,看看成果吧

#include#define uchar unsigned char#define uint unsigned int#define dp P0char code DuanMa[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40}; //单个数码管显现数char code fenjie[]={0,0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f};char code WeiMa[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f}; //数码管的位挑选:从0到7.sbit LATCH1=P2^6;	//	操控数码管段的位sbit LATCH2=P2^7; //	操控数码管位的位void delay(unsigned int t){while(--t);}void main(){int i,j,k;while(1){delay(5000);for(i=0;i<7;i++)	//段码{ for(j=0;j<8;j++)	//位码{ for(k=0;k<10;k++) //调理k的值可调理扫描时间{dp=WeiMa[j]; //取位码LATCH2=1;     LATCH2=0; dp=DuanMa[i]; //取段码 LATCH1=1;     LATCH1=0;delay(2500);dp=fenjie[i]; //取段码 LATCH1=1;     LATCH1=0;dp=WeiMa[7]; //取位码LATCH2=1;     LATCH2=0; delay(50);dp=0; //取段码 清零	  减小余晖影响LATCH1=1;     LATCH1=0;dp=WeiMa[j]; //取位码LATCH2=1;     LATCH2=0; delay(1000); }}}	 //闪耀8for(k=0;k<10;k++){dp=fenjie[7]; //取段码 LATCH1=1;     LATCH1=0;dp=WeiMa[7]; //取位码LATCH2=1;     LATCH2=0;delay(6000);delay(6000);dp=0; //取段码 LATCH1=1;     LATCH1=0;dp=WeiMa[7]; //取位码LATCH2=1;     LATCH2=0;delay(6000);}	    }	 }	  

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/qiche/318049.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部