【发布时间】:2015-09-21 01:15:32
【问题描述】:
所以我要做的就是创建一个函数来打开和关闭 LED,这将被调用到 main 中。 LED 会亮起,但不会亮起和熄灭。我的代码有什么问题?
我正在使用 ATmega328p 板和 Atmel Studio 6.2
#define F_CPU 16000000UL // 16MHz clock from the debug processor
#include <avr/io.h>
#include <util/delay.h>
dot();
int main()
{
DDRB |= (1<<DDB5);
while(1)
{
dot();
}
}
int dot()
{
PORTB |= (1<<PORTB5); // Set port bit B5 to 1 to turn on the LED
_delay_ms(200); // delay 200mS
PORTB |= (0<<PORTB5); // Set port bit B5 to 0 to turn on the LED
_delay_ms(200); // delay 200mS
}
【问题讨论】: