|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
数码管滚动的仿真和程序2 m% V1 S1 F$ T! _: ~. @
仿真原理图如下(proteus仿真工程)% ~, _& w$ M6 ~3 [- R
( ^* A* @# W7 P" ~# Q) L" l
+ X% h0 J e: j- s单片机源程序如下:
- V5 x* F9 x: K& A- #include <reg51.h>
- #include <intrins.h>
- int smg[] = {0xc0,0xf9,0xa4,0xb0,0x91,0xa2,0x82,0xf8,0x80,0x90}; //0-9字模 段选
- //0 1 2 3 4 5 6 7 8 9
- int wx[] = {0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f}; //1-8位 位选
- int xh[] = {0xa4,0xc0,0xa4,0xc0,0xf9,0xc0,0xf9,0xf9,0xc0,0x92,0xff,0xff}; //2020101105
- void delay(unsigned int xms) //延时函数
- {
- unsigned int x,y;
- for(x=xms;x>0;x--)
- for(y=110;y>0;y--);
- }
- int main() //实现动态数码管滚动
- {
- int i=0,j=0,k=0,m=0x80; //0x80 1000 0000
- while(1)
- {
- for(k=75;k>0;k--) //改变滚动速度
- {
- for(j=0;j<8;j++)
- {
- P0 = 0xff; //显示空
- P0 = xh[(j+i)%12]; //改变段选
- m = _crol_(m,1); //改变位选
- P2 = m;
- delay(1);
- }
- }
- i += 1;
- }
- } o7 H! C+ k, u% F; ~* P) M
3 I' f# _1 X2 |2 `, f K, a' W% [) r! i |
|