|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
数码管滚动的仿真和程序
% G; X! m, g8 v3 G仿真原理图如下(proteus仿真工程)
3 S8 W7 @- C& h0 O. q O5 n' H ; p6 S" h2 }$ C! B% n1 a1 v
2 ?7 C* v$ z6 [# F& K, L( f" c4 s l单片机源程序如下:
2 \7 Z" W7 Q0 x: z- #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;
- }
- }
. z5 d7 A- P3 T; W 0 L0 `$ r# i4 Z: s `
|
|