2013
Dependencies: BMP085_2 SDFileSystem mbed
Fork of cansat new by
Diff: main.cpp
- Revision:
- 1:6dc59f48b649
- Parent:
- 0:2c21bfd10524
- Child:
- 2:e093c70066d0
diff -r 2c21bfd10524 -r 6dc59f48b649 main.cpp --- a/main.cpp Sun Jul 28 06:01:30 2013 +0000 +++ b/main.cpp Sun Jul 28 06:44:40 2013 +0000 @@ -1,8 +1,10 @@ #include "mbed.h" - +//#include "SDFileSystem.h" + +//SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board Serial xbee(p13,p14); // tx, rx -/*Timeout dater; -LocalFileSystem local("local");*/ +/*Timeout dater;*/ +LocalFileSystem local("local"); AnalogIn temp_in(p20); AnalogIn acc_x(p17); @@ -10,14 +12,14 @@ AnalogIn acc_z(p19); AnalogIn v_out(p16); AnalogIn light_in(p15); - - int main() { float r_temp, temp; float vo,ax,ay,az, light; -// FILE*fp = fopen("/local/CanSat.txt", "a"); + + FILE* fp = fopen("/local/CanSat.txt", "a"); + unsigned count = 0; while(1){ temp = temp_in; @@ -27,21 +29,27 @@ az = acc_z/10; light = light_in/10*33; r_temp = temp_in * 3.3 * 100 ; -/* fprintf(fp, "RoomTemp:%5.2f, ",r_temp); - fprintf(fp,"Temt:%5.2f, ",((vo*8-6)/25)); - fprintf(fp,"acc_x:%5.2f, ",(ax*33-1.65)/0.66); - fprintf(fp,"acc_y:%5.2f, ",(ay*33-1.65)/0.66); - fprintf(fp,"acc_z:%5.2f",(az*33-1.65)/0.66); - fprintf(fp,"light:%5.2f",light); - fprintf(fp,"\n\r");*/ - xbee.printf("RoomTemp:%5.2f, ",r_temp); - xbee.printf("Temt:%5.2f, ",((vo*8-6)/25)); - xbee.printf("acc_x:%5.2f, ",(ax*33-1.65)/0.66); - xbee.printf("acc_y:%5.2f, ",(ay*33-1.65)/0.66); - xbee.printf("acc_z:%5.2f",(az*33-1.65)/0.66); - xbee.printf("light:%5.2f",light); - xbee.printf("\n\r"); - wait(1.0); + + + fprintf(fp, "T %5.2f ",r_temp); + fprintf(fp, "H %5.2f ",(vo*8-6)/25); + fprintf(fp, "X %5.2f ",(ax*33-1.65)/0.66); + fprintf(fp, "Y %5.2f ",(ay*33-1.65)/0.66); + fprintf(fp, "Z %5.2f ",(az*33-1.65)/0.66); + fprintf(fp, "L %5.2f",light); + fprintf(fp,"\n\r"); + + if (count % 10 == 0) { + xbee.printf("T %5.2f ",r_temp); + xbee.printf("H %5.2f ",((vo*8-6)/25)); + xbee.printf("X %5.2f, ",(ax*33-1.65)/0.66); + xbee.printf("Y %5.2f, ",(ay*33-1.65)/0.66); + xbee.printf("Z %5.2f",(az*33-1.65)/0.66); + xbee.printf("L %5.2f",light); + xbee.printf("\n\r"); + }//if + + wait(0.1); } // fclose(fp); -} \ No newline at end of file +}