|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
数码管滚动的仿真和程序5 u8 ^5 \2 n- c# j" o
仿真原理图如下(proteus仿真工程)! Q: z& | z' u/ C+ q. r' j1 c
![]()
0 t9 q4 w7 l$ y9 e- C6 M
8 B# l' J' D5 N6 \6 [1 z单片机源程序如下:
W6 t5 T, K3 F! `( I- #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;
- }
- }3 k# j! Z& D0 s& |: _" x# Y3 `
: F9 x5 ]( g6 m! @. f' c
|
|