源代码:
/*
* _3.c
*
* Created: 2011-4-5 19:34:47
* Author: xmphoenix.fish
*/
#include <avr/io.h>
#include<util/delay.h>
#define F_CPU 8000000UL
#define key_down() (PINB &_BV(PB5))
#define real_switch() PORTE^=_BV(PE3)
int main(void)
{
DDRE = 0xff;PORTE = 0xff;
DDRB = 0x00;PORTB = 0xff;
while(1)
{
if (!key_down())
{
while(!key_down());
real_switch();
_delay_ms(20);
}
}
}
截图: