Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of rtos_mutex by
main.cpp
00001 #include "mbed.h" 00002 #include "xbee.h" 00003 #include "LSM9DS1.h" 00004 xbee xbee1(p13,p14,p5); //Initalise xbee_lib 00005 00006 DigitalOut led1(LED1); 00007 DigitalOut led2(LED2); 00008 00009 DigitalOut led3(LED3); 00010 Serial pc(USBTX, USBRX); //Initalise PC serial comms 00011 char read_data1[202]; //Xbee buffer size is 202 bytes 00012 char send_data[202]; //Xbee buffer size is 202 bytes 00013 char read_data[202]; //Xbee buffer size is 202 bytes 00014 00015 00016 //also setting unused analog input pins to digital outputs reduces A/D noise a bit 00017 //see http://mbed.org/users/chris/notebook/Getting-best-ADC-performance/ 00018 DigitalOut P16(p16); 00019 DigitalOut P17(p17); 00020 DigitalOut P18(p18); 00021 DigitalOut P19(p19); 00022 DigitalOut P20(p20); 00023 int main() 00024 { 00025 LSM9DS1 imu(p9, p10, 0xD6, 0x3C); 00026 imu.begin(); 00027 00028 00029 //pc.baud(9600); 00030 00031 //Thread thread(led2_thread); 00032 imu.readAccel(); 00033 double t=imu.az; 00034 while(1) { 00035 led1=0; 00036 led2=0; 00037 imu.readAccel(); 00038 t=imu.az; 00039 00040 while(abs(t-imu.az)<4000){ 00041 00042 imu.readAccel(); 00043 t=imu.az; 00044 pc.printf("gyro: %d %d %d\n\r", imu.ax, imu.ay, imu.az); 00045 wait(.5); 00046 imu.readAccel(); 00047 } 00048 //pc.scanf("%s",send_data); //Read data from serial console 00049 led1=1; 00050 xbee1.SendData("hey"); //Send data to XBee 00051 led2=1; 00052 // xbee1.RecieveData(read_data1,0); //Read data from the XBee 00053 //led1=0; 00054 wait(5); 00055 } 00056 }
Generated on Fri Jul 22 2022 21:17:38 by
1.7.2
