0% found this document useful (0 votes)
33 views

#Include #Include #Include "UART.h": "/r/ncommand: %S" "Response:"

This C program initializes UART communication on two ports and uses it to send commands and messages to an XBee module. It enters and exits the XBee command mode several times to change the network ID and send strings on different IDs. The main function initializes UART ports, calls the xbeeString function to send commands/messages with delays, and enters an infinite loop at the end.

Uploaded by

sumit valsangkar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

#Include #Include #Include "UART.h": "/r/ncommand: %S" "Response:"

This C program initializes UART communication on two ports and uses it to send commands and messages to an XBee module. It enters and exits the XBee command mode several times to change the network ID and send strings on different IDs. The main function initializes UART ports, calls the xbeeString function to send commands/messages with delays, and enters an infinite loop at the end.

Uploaded by

sumit valsangkar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

main.

1 #include <lpc214x.h>
2 #include <stdio.h>
3 #include "UART.h"
4  
5 void delay(unsigned int time)
6 {
7     unsigned int i,j;
8     for(i=0;i<time;i++)
9         for(j=0;j<10000;j++);
10 }
11  
12 void xbeeString(unsigned char *ch)          //function to send a command to zigbee
13 {
14     printf("\r\ncommand: %s",ch);
15     printf("response:");
16     UART1_PutS(ch);
17 }
18  
19 int main()
20 {
21     Uart0Init(9600);
22     Uart1Init(9600);
23     xbeeString("+++");                      //enter command mode
24     delay(1000);
25     xbeeString("AT\r\n");                   //check if all ok
26     delay(1000);
27     xbeeString("ATID 10\r\n");              //change network id to 10
28     delay(1000);
29     xbeeString("ATCN\r\n");                 //exit command mode
30     delay(1000);
31     xbeeString("HELLO.... This is PAN ID 10\r\n");      //send a string on network id 10
32     delay(1000);
33     xbeeString("+++");                      //enter command mode
34     delay(1000);
35     xbeeString("ATID 15\r\n");              //change network id to 15
36     delay(1000);
37     xbeeString("ATCN\r\n");                 //exit command mode
38     delay(1000);
39     xbeeString("HELLO.... This is PAN ID 15\r\n");      //send a string on network id 15
40     delay(1000);
41  
42     while(1);
43 }

You might also like