代码:
#include<reg51.h>
#include<intrins.h>
#define uint unsigned int
#define uchar unsigned char
void delay(uint x)
{
uchar i;
while(x--)
{
for(i=0;i<120;i++);
}
}
void main()
{
uchar c=0xe0;
P1 = 0x80;
while(1)
{
c = _crol_(c,1);
SBUF = c;
while(TI==0);
TI = 0;
delay(400);
}
}
效果:
两个IO口扩展成8个。