#include<pic.h>
unsigned char tab1[]={0x44,0xF5,0x1C,0x94,0xA5,0x86,0x06,0xF4,0x04,0x84,0x24,0x07,0x4E,0x15,0x0E,0x2E,0xff};
unsigned char tab2[]={0x40,0xF1,0x18,0x90,0xA1,0x82,0x02,0xF0,0x00,0x80,0x20,0x03,0x4a,0x11,0x0a,0x2a,0xfb};
#define data_595 RD0//串行数据输入端口
#define sck RD1//移位寄存器工作时钟
#define rck RD2//锁存器下载数据时钟
void delay(int x)
{
int j;
while(x--)
{
for(j=0;j<110;j++)
{
}
}
}
void send595data(int x)
{
int i;
for(i=0;i<8;i++)
{
sck=0;
if((x&0x80)==0)
data_595=0;
else data_595=1;
x=x<<1;
sck=1;
}
}
void output_595(void)//输出显示数据
{
rck=0;
delay(5);
rck=1;
delay(5);
}
void display()
{
send595data(tab1[1]);
send595data(tab1[2]);
send595data(tab1[3]);
send595data(tab2[5]);
output_595();
}
void main()
{
TRISD=0;
while(1)
{
display();
}
}
|