- UID
- 695063
- 阅读权限
- 15
- 推广
-
- 幽默
-
- 注册时间
- 2014-12-13
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2015-4-27 12:30:16
|
显示全部楼层
#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
sbit shp=P0^2;
sbit ds=P0^1;
sbit stp=P0^0;
uchar table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
uchar table1[]={0x01,0x02,};
unsigned char BBBB[2]=0;
void delay(uint t)
{
uchar i;
for(;t>0;t--)for(i=5480;i>0;i--);
}
void writedata(uchar kk)
{
uchar nn;
for(nn=0;nn<8;nn++)
{ shp=0;
ds=kk&0x80;
kk=kk<<1;
shp=1;
}
}
void writedata1(uchar kk)
{
uchar nn;
for(nn=0;nn<8;nn++)
{ shp=0;
ds=kk&0x80;
kk=kk<<1;
shp=1;
}
}
void send595()
{
stp=0;
delay(1);
stp=1;
}
void main ()
{
unsigned int a=0;
unsigned char b=0;
unsigned char j=0;
unsigned char c=0;
while(1)
{
for(a=0;a<2000;a++);
b++;
if(b==100)
{
b=0;
c++;
BBBB[0]=c%10;
BBBB[1]=c/10%10;
}
switch(j)
{
case 0: writedata(table[BBBB[0]]);writedata1(table1[1]);j++;break;
case 1: writedata(table[BBBB[1]]);writedata1(table1[0]);j=0;break;
default:break;
}
send595();
delay(20);
}
} |
|