编写一个程序并编译成hex文件:
#include <iom16v.h>
void delay_ms(unsigned int k)
{
unsigned int i,j;
for (i=0;i<k;i++)
for (j=0;j<1140;j++);
}
void main()
{
DDRB=0xff; //PB口全部设置为输出
while (1)
{
PORTB=0xff; //点亮二极管
delay_ms(500); //延迟500毫秒
PORTB=0x00; //熄灭二极管
delay_ms(500);
}
}