单片机C语言程序设计:8 只数码管滚动显示数字、字符
/* 名称:8 只数码管滚动显示单个数字
说明:数码管从左到右依次滚动显示
0~7,程序通过每次仅循环选通一只数码
管
*/
#includereg51.h>
#includeintrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar code DSY_CODE[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
//延时
void DelayMS(uint x)
{
uchar t;
while(x--) for(t=0;t120;t++);
}
//主程序
void main()
{
}
uchar i,wei=0x80;
while(1)
{
for(i=0;i8;i++)
{
P2=0xff; //关闭显示
wei=_crol_(wei,1);
P0=DSY_CODE[i];发送数字段码
P2=wei; //发送位码
DelayMS(300);
}
}
/* 名称:8 只数码管动态显示多个不同字符
说明:数码管动态扫描显示 0~7。
*/
#includereg51.h>
#includeintrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar code DSY_CODE[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
c语言相关文章:c语言教程
评论