Snehitha Reddy
/
AlarmSys1
alarm system
Fork of rtos_mutex by
main.cpp
- Committer:
- sreddy47
- Date:
- 2016-04-29
- Revision:
- 5:802a7c5a4b27
- Parent:
- 1:0f886ffbe0c1
File content as of revision 5:802a7c5a4b27:
#include "mbed.h" #include "xbee.h" #include "LSM9DS1.h" xbee xbee1(p13,p14,p5); //Initalise xbee_lib DigitalOut led1(LED1); DigitalOut led2(LED2); DigitalOut led3(LED3); Serial pc(USBTX, USBRX); //Initalise PC serial comms char read_data1[202]; //Xbee buffer size is 202 bytes char send_data[202]; //Xbee buffer size is 202 bytes char read_data[202]; //Xbee buffer size is 202 bytes //also setting unused analog input pins to digital outputs reduces A/D noise a bit //see http://mbed.org/users/chris/notebook/Getting-best-ADC-performance/ DigitalOut P16(p16); DigitalOut P17(p17); DigitalOut P18(p18); DigitalOut P19(p19); DigitalOut P20(p20); int main() { LSM9DS1 imu(p9, p10, 0xD6, 0x3C); imu.begin(); //pc.baud(9600); //Thread thread(led2_thread); imu.readAccel(); double t=imu.az; while(1) { led1=0; led2=0; imu.readAccel(); t=imu.az; while(abs(t-imu.az)<4000){ imu.readAccel(); t=imu.az; pc.printf("gyro: %d %d %d\n\r", imu.ax, imu.ay, imu.az); wait(.5); imu.readAccel(); } //pc.scanf("%s",send_data); //Read data from serial console led1=1; xbee1.SendData("hey"); //Send data to XBee led2=1; // xbee1.RecieveData(read_data1,0); //Read data from the XBee //led1=0; wait(5); } }