求大神们救救孩子,因为C语言学的比较差,所以写了一周都没写正确要求(1)数码管从右往左显示(类似流水灯)117331就是一开始数码管:(第一次显示)_ _ _1。(第二次显示)_ _ 11。(第三次显示)_ 117。 (第四次显示)1173。(第五次显示)1733。(第六次显示)7331。 (第七次显示)331_。(第八次显示)31_ _。(第九次显示)1_ _ _。就是像流水灯一样从右往左动态显示 ,下划线是代表没有显示,在这里标出来方便大神们明白!图是计算器的仿真,也能显示的。救救孩子吧!
这是四位数码管从右从左流动显示,像滚动字幕一样的。用不着矩阵按键哪。
其实程序很简单,没那么复杂。程序如下
#include <reg51.h>
#define uchar unsigned char
#define uint unsigned int
uchar code tab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x00};//共阴段码码,0x00为灭
void delay()//延时子程序
{
uint y;
for(y=400;y>0;y--);
}
void main()
{
uchar n,x;
while(1)
{
n++;
if(n>50)//n为显示一屏显示次数,n大小可调节流动速度
{
n=0;
x++;//从下一个位置开始显示
if(x>8)x=0;
}
}
}
仿真结果