jkk

Dependencies:   mbed RGB-fun HC_SR04_Ultrasonic_Library xbee_lib

Committer:
pimani
Date:
Fri Apr 10 15:34:46 2020 +0000
Revision:
1:7fbedf384fe9
Parent:
0:9cbddcc86466
Transmitter codes

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tristanjph 0:9cbddcc86466 1 #include "mbed.h"
tristanjph 0:9cbddcc86466 2 #include "xbee.h"
pimani 1:7fbedf384fe9 3 #include "ultrasonic.h"
pimani 1:7fbedf384fe9 4 #include "hcsr04.h"
pimani 1:7fbedf384fe9 5
pimani 1:7fbedf384fe9 6 //sonars
pimani 1:7fbedf384fe9 7 HCSR04 front1(p13,p12);
pimani 1:7fbedf384fe9 8 HCSR04 front2(p14,p12);
pimani 1:7fbedf384fe9 9 HCSR04 back1(p15,p12);
pimani 1:7fbedf384fe9 10 HCSR04 back2(p16,p12);
pimani 1:7fbedf384fe9 11
pimani 1:7fbedf384fe9 12 //IR sensors
pimani 1:7fbedf384fe9 13 InterruptIn PIR_Left(p17);
pimani 1:7fbedf384fe9 14 InterruptIn PIR_Right(p18);
pimani 1:7fbedf384fe9 15
pimani 1:7fbedf384fe9 16 //SHOWING SENDING STATUS
pimani 1:7fbedf384fe9 17 BusOUT sending(LED1,LED2,LED3,LED4);
tristanjph 0:9cbddcc86466 18
tristanjph 0:9cbddcc86466 19 xbee xbee1(p9,p10,p11); //Initalise xbee_lib
tristanjph 0:9cbddcc86466 20 Serial pc(USBTX, USBRX); //Initalise PC serial comms
tristanjph 0:9cbddcc86466 21
tristanjph 0:9cbddcc86466 22 int main()
tristanjph 0:9cbddcc86466 23 {
tristanjph 0:9cbddcc86466 24 char send_data[202]; //Xbee buffer size is 202 bytes
tristanjph 0:9cbddcc86466 25 char read_data[202]; //Xbee buffer size is 202 bytes
tristanjph 0:9cbddcc86466 26
tristanjph 0:9cbddcc86466 27 while(1) {
tristanjph 0:9cbddcc86466 28 pc.scanf("%s",send_data); //Read data from serial console
tristanjph 0:9cbddcc86466 29 xbee1.SendData(send_data); //Send data to XBee
tristanjph 0:9cbddcc86466 30 xbee1.RecieveData(read_data,0); //Read data from the XBee
tristanjph 0:9cbddcc86466 31 pc.printf("You said:%s",read_data);
tristanjph 0:9cbddcc86466 32 }
tristanjph 0:9cbddcc86466 33 }