|
本帖最后由 135kor 于 2020-3-21 01:14 编辑
0-a,16位数循环滚动
#include <reg52.h>
#include <MyType.h>
#include <intrins.h>
uint8 code Segment[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};
sbit SegSec=P2^6;
sbit PosSec=P2^7;
#define DataPort P0
void Delay(int ms);
void main()
{
uint16 i=0,j,k,x=0xfe;
while(1)
{
for(j=0;j<23;j++)
{
for(i=100;i>0;i--)
{
//1
DataPort=0xfe;
PosSec=1;
PosSec=0;
DataPort=Segment[j];
SegSec=1;
SegSec=0;
DataPort=0xff;
Delay(1);
//2
DataPort=0xfd;
PosSec=1;
PosSec=0;
DataPort=Segment[j+1];
SegSec=1;
SegSec=0;
DataPort=0xff;
Delay(1);
//3
DataPort=0xfb;
PosSec=1;
PosSec=0;
DataPort=Segment[j+2];
SegSec=1;
SegSec=0;
DataPort=0xff;
Delay(1);
//4
DataPort=0xf7;
PosSec=1;
PosSec=0;
DataPort=Segment[j+3];
SegSec=1;
SegSec=0;
DataPort=0xff;
Delay(1);
//5
DataPort=0xef;
PosSec=1;
PosSec=0;
DataPort=Segment[j+4];
SegSec=1;
SegSec=0;
DataPort=0xff;
Delay(1);
//6
DataPort=0xdf;
PosSec=1;
PosSec=0;
DataPort=Segment[j+5];
SegSec=1;
SegSec=0;
DataPort=0xff;
Delay(1);
//7
DataPort=0xbf;
PosSec=1;
PosSec=0;
DataPort=Segment[j+6];
SegSec=1;
SegSec=0;
DataPort=0xff;
Delay(1);
//8
DataPort=0x7f;
PosSec=1;
PosSec=0;
DataPort=Segment[j+7];
SegSec=1;
SegSec=0;
DataPort=0xff;
Delay(1);
}
}
}
}
void Delay(int ms)
{
int i,j;
for(i=ms;i>0;i--)
for(j=112;j>0;j--);
}
|
|