原理图我就不画了4个p口全部接上led灯即可,下面是控制程序:
#include
#include #define uint unsigned int
#define uchar unsigned char
uchar code table0[]={0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00};//P0-P7依次点亮
uchar code table1[]={0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff};//P0-P7依次熄灭
uchar code table2[]={0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01,0x00};//P7-P0依次点亮
uchar code table3[]={0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff};//P7-P0依次熄灭
uchar temp,aa,bb,temp,temp1;
void delay(uint z);
void h();
void hh();
void hhh();
void hhhh();
void init();
void main()//主函数
{
init();
while(520)//大循环
{
h();
hh();
hhh();
hhhh();
}
}
void delay(uint z)//延时函数
{
uint x,y;
for(x=z;x>0;x--)