Basic Xbee reciever with application board. Uses LCD to display up or down.

Dependencies:   C12832 mbed

Committer:
Perijah
Date:
Sat Feb 20 11:56:30 2016 +0000
Revision:
0:ee395ccc1347
Basic Xbee reciever with applicationboard

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Perijah 0:ee395ccc1347 1 #include "mbed.h"
Perijah 0:ee395ccc1347 2 #include "C12832.h"
Perijah 0:ee395ccc1347 3
Perijah 0:ee395ccc1347 4 Serial xbee(p9,p10); //Create serial object
Perijah 0:ee395ccc1347 5 char a;
Perijah 0:ee395ccc1347 6 C12832 lcd(p5, p7, p6, p8, p11); //Used for the LCD
Perijah 0:ee395ccc1347 7 DigitalOut nReset(p30); //reset pin of the xbee
Perijah 0:ee395ccc1347 8
Perijah 0:ee395ccc1347 9
Perijah 0:ee395ccc1347 10 int main()
Perijah 0:ee395ccc1347 11 {
Perijah 0:ee395ccc1347 12 xbee.baud(57600); //set the baud rate of the xbee. (9600 standard)
Perijah 0:ee395ccc1347 13 while(1) {
Perijah 0:ee395ccc1347 14 lcd.locate(0,3);
Perijah 0:ee395ccc1347 15 wait_ms(500);
Perijah 0:ee395ccc1347 16
Perijah 0:ee395ccc1347 17 if(xbee.readable()) { //Checks if the data is readable
Perijah 0:ee395ccc1347 18 a = xbee.getc(); //Get the first character that's in the buffer
Perijah 0:ee395ccc1347 19 }
Perijah 0:ee395ccc1347 20 if(a=='u') { //detects if joystick is pressed up
Perijah 0:ee395ccc1347 21
Perijah 0:ee395ccc1347 22 lcd.cls(); //NOT SURE: wipes LCD screen.
Perijah 0:ee395ccc1347 23 lcd.printf("up");
Perijah 0:ee395ccc1347 24
Perijah 0:ee395ccc1347 25 }
Perijah 0:ee395ccc1347 26 if(a=='d') { //detects if yoystick is pressed down
Perijah 0:ee395ccc1347 27
Perijah 0:ee395ccc1347 28 lcd.cls();
Perijah 0:ee395ccc1347 29 lcd.printf("down");
Perijah 0:ee395ccc1347 30
Perijah 0:ee395ccc1347 31 }
Perijah 0:ee395ccc1347 32
Perijah 0:ee395ccc1347 33
Perijah 0:ee395ccc1347 34 }
Perijah 0:ee395ccc1347 35 }