#include
#include
typedef unsigned char uchar;
void intx();
uchar code led_table[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,
0x80,0x90,0x88,0x83,0xC6,0xA1,0x86,0x8E};
void delay(void) //差错 0us
{
unsigned char a,b,c;
for(c=167;c>0;c–)
for(b=171;b>0;b–)
for(a=16;a>0;a–);
_nop_(); //if Keil,require use intrins.h
}
void main()
{
IT1=1;
EA=1;
EX1=1;
//ES=1;
SCON=0;
P1=0;
while(1);
}
void intx() interrupt 2
{
uchar i;
P1=0;
for(i=0;i<16;i++)
{
SBUF=led_table[i];
while(!TI);
TI=0;
delay();
}
}
》》》》》》》》》》》》》》位操作《〈〈〈〈〈〈〈〈〈〈〈〈〈〈〈
#include
#include
typedef unsigned char uchar;
void sendleddata(uchar);
uchar bdata dat;
sbit ab=P3^0;
sbit clk=P3^1;
sbit dat0=dat^0;
uchar code ledtable[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,
0x80,0x90,0x88,0x83,0xC6,0xA1,0x86,0x8E};
void delay(void) //差错 0us
{
unsigned char a,b,c;
for(c=167;c>0;c–)
for(b=171;b>0;b–)
for(a=16;a>0;a–);
_nop_(); //if Keil,require use intrins.h
}
void main()
{
uchar i;
while(1)
{
for(i=0;i<8;i++)
{
sendleddata(i);
delay();
}
}
}
void sendleddata(uchar k)
{
uchar i;
dat=ledtable[k];
for(i=0;i<8;i++)
{
ab=dat0;
clk=0;
_nop_();
clk=1;
_nop_();
dat>>=1;
}
}