![7e93b09e4a6c19cfbf25ca5ba148e167.png](https://i-blog.csdnimg.cn/blog_migrate/e0ad6c3fdcfe2cb25b8d05f91a9bf467.jpeg)
使用IAR编写代码烧入zigbee。
IAR可以调试zigbee代码,建议使用。
//引用头
#include <iocc2530.h>
#define D1 P1_1
#define D2 P1_0
#define D3 P1_4
#define D4 P1_3
#define Sw1 P1_2
//延时函数
void delay(unsigned int a)
{
while(a--);
}
延时函数用来计时,这次写流水灯效果。
初始化函数
void init()
{
P1SEL &=~0xff;
P1DIR |= 0x1b;
P1DIR &=~0x04;
}
灯的效果。
//1亮到16
void light()
{
for(int a=0; a<16; a++)
{
P1 = a;
delay(60000);
if(a>16)a=0;
}
}
主函数
void main()
{
init();
while(1)
{
light();
}
}
P1SEL是寄存器,选择P1口的输入输出。0输入1输出。
delay是可选延时,让系统处于什么都不运行的空状态时间,达到等待的目的。