单片机共阳数码管显示
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
//使用共阳数码管
uchar code shi_zi[]={0XC0,0XF9,0XA4,0XB0,0X99,0X92,0X82,0XF8,0X80,0X90,0XFF};//code用于指定变量
void dealy(uint ms)//延时1MS无路
{
uchar i,j;
for(i=0;i<ms;i++)
for(j=0;j<110;j++);
}
void main()
{
uchar x=0;
P1=0XFF;//全部灭灯
while(1)
{
P1=shi_zi[x];
x=(x+1)%10;//取个位数
dealy(180);
}
}








最新发布