#include <reg51.h>
#include <intrins.h>
#define nop _nop_()
#define uchar unsigned char
#define uint unsigned int
uchar seg_code[12] ={0xc0,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0xaa,0x00};
sbit STCP = P3^5;
sbit DS = P3^4;
sbit SHCP = P3^6;
void delay(uchar t)
{
uchar i;
while(t--)
{
for(i=0;i<120;i++);
}
}
void input_595(uchar dat) //將數據放到移位寄存器中
{
uchar i;
for(i=0;i<8;i++)
{
dat<<=1;
DS = CY;
SHCP = 0;
nop;
nop;
SHCP = 1;
nop;
nop;
}
SHCP = 0;
}
void input_cuncu() //將數據放入存儲寄存器中
{
STCP = 0;
nop;
nop;
STCP = 1;
nop;
nop;
SHCP = 0;
nop;
nop;
}
void main()
{
while(1)
{
input_595(seg_code[0]);
input_595(seg_code[10]);
input_cuncu();
}
}