|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
数码管滚动的仿真和程序1 z7 B1 ~" q; `2 R
仿真原理图如下(proteus仿真工程)
7 [. c) u4 j4 i( T1 p! }; k% l( M : q$ {2 p* A2 I( N0 H
: R& @; T# Q& k% k3 {
单片机源程序如下:
n% l& @3 B/ t/ x4 k* a& M7 \- #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;
- }
- }; B J$ s; l/ g
5 Q" B8 z: K/ _ |
|