|
#include <reg51.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit P1_0=P1^0;
sbit P1_1=P1^1;
sbit P1_2=P1^2;
void delay();
void main()
{
unsigned char num=0xfe,c=0;
EX0=1;EA=1;IT0=0;
for(c=0;c<8;c++)
{
P0=num;
delay();
num=_cror_(num,1);
delay();
}
for(c=0;c<8;c++)
{
P0=num;
delay();
num=_crol_(num,1);
delay();
}
P0=0x00;delay();P0=0xff;delay();
P0=0x00;delay();P0=0xff;delay();
P0=0x00;delay();P0=0xff;delay();
}
void int0() interrupt 0
{
if(P1_0==0)
{
unsigned char num=0xfe,c=0;
for(c=0;c<8;c++)
{
P0=num;num=_crol_(num,1);delay();
}
}
if(P1_1==0)
{
unsigned char num=0xfe,c=0;
for(c=0;c<8;c++)
{
P0=num;num=_cror_(num,1);delay();
}
}
if(P1_2==0 )
{
P0=0x00;delay();P0=0xff;delay();
P0=0x00;delay();P0=0xff;delay();
P0=0x00;delay();P0=0xff;delay();
}
}
void delay()
{
unsigned char a,b;
for(a=0;a<250;a++)
for(b=0;b<200;b++);
}
|
評(píng)分
-
查看全部評(píng)分
|