#include <reg51.h>
#include <intrins.h>
#define uchar unsigned char
sbit sh=P3^0;
sbit ds=P3^1;
sbit st=P3^2;
extern uchar pp1=0x08;
uchar code TAB[]={
0x00, 0xc0, 0x0c, 0xc0, 0x0d, 0xbc, 0x19, 0xec, 0x3b, 0x78, 0x7e, 0x60, 0x1b, 0x78, 0x1b, 0x6c,
0x18, 0xe0, 0x00, 0x0c, 0x0d, 0x86, 0x3c, 0xf0, 0x76, 0x18, 0x03, 0xfc, 0x00, 0x00, 0x00, 0x00};
void delay();
void ls138(void);
void hc595(uchar da);
void main()
{
int i;
while(1)
{
for(i=0;i<16;i++)
{
hc595(TAB[2*i+1]);
hc595(TAB[2*i]);
ls138();
}
}
}
void ls138()
{
P1=pp1;
delay();
pp1++;
}
void hc595(uchar da)
{
int n;
st=0;
for(n=0;n<8;n++)
{
da=da<<1;
ds=CY;
sh=0;
delay();
sh=1;
delay();
}
st=1;
}
void delay()
{
int n;
for(n=0;n<100;n++)
{
_nop_();
}
} |