如何用独立按键控制一个led灯,按下时候灯亮,下面我写的,求解失败原因及方法,谢谢
#include<iom16v.h>
#include<macros.h>
#define unit unsigned int
#define uchar unsigned char
void show()
{
DDRA|=0X84;
PORTA|=BIT(2);
PORTA&=~BIT(7);
DDRB=0XFF;
PORTB=0XFE;
}
void main()
{
uchar key;
DDRD|=0X0F;
PORTD|=0X0F;
DDRD&=0XF0;
key=PIND;
key=key&0x0f;
if(key==0x0E)
{show();}
}
|