8位共阳数码管从左到右,从右到左分别显示8个字符
- #include <reg51.h>
- #include <intrins.h>
- typedef unsigned char u8;
- typedef unsigned int u16;
- u8 code dis_code[]={0x88,0x83,0xc6,0xa1,0x86,0x8e,0x89,0x8c,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80};
- void delay(u16 t)
- {
- while(t--) ;
- }
- void main()
- {
- u16 i,j;
- while(1)
- {
- j=0x01;
- for(i=0;i<8;i++)
- {
- P2=j;
- j=_crol_(j,1);
- P0=dis_code[i];
- delay(50000);
- }
- j=0x80;
- for(i=7;i>=0;i--)
- {
- P2=j;
- j=_cror_(j,1);
- P0=dis_code[i];
- delay(50000);
- }
- i=0;
- }
- }
复制代码
|