标题: 初学者基于51单片机数码管9到0循环显示 [打印本页]

作者: 33332    时间: 2018-6-30 18:27
标题: 初学者基于51单片机数码管9到0循环显示
#include<reg51.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar code DSY_CODE[]={0x90,0x80,0xf8,0x82,0x92,0x99,0xb0,0xa4,0xf9,0xc0,0xFF};

void DelayMS(uint x)
{
uchar t;
while(x--) for(t=0;t<120;t++);
}

void main()
{

uchar i=0;
P2=0x00;
while(1)
{
P2=~DSY_CODE[i];
i=(i+1)%10;
DelayMS(180);
}
}

111111111111.JPG (81.63 KB, 下载次数: 53)

111111111111.JPG





欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1