迅维网
标题:
三个按键,控制不同状态的LED
[打印本页]
作者:
バ幸福De右岸
时间:
2016-3-18 17:45
标题:
三个按键,控制不同状态的LED
#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=0x00;delay()
P0=0x00;delay()
0=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()0=0xff;delay();
P0=0x00;delay()0=0xff;delay();
P0=0x00;delay()0=0xff;delay();
}
}
void delay()
{
unsigned char a,b;
for(a=0;a<250;a++)
for(b=0;b<200;b++);
}
Proteus线路图
登录/注册后看高清大图
欢迎光临 迅维网 (https://www.chinafix.com/)
Powered by Discuz! X3.4