0、01秒ごとに本体にデータを保存 1秒ごとに無線通信をするプログラム

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
yattu0914
Date:
Sun Jul 21 13:26:58 2013 +0000
Commit message:
???????0.01????
; ?????1???????????
; ?????????????

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 6613b486c090 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Jul 21 13:26:58 2013 +0000
@@ -0,0 +1,56 @@
+#include "mbed.h"
+
+Serial xbee(p13,p14);  // tx, rx 
+Ticker writeTimer;
+LocalFileSystem local("local");
+
+AnalogIn temp_in(p20);
+AnalogIn acc_x(p17);
+AnalogIn acc_y(p18);
+AnalogIn acc_z(p19);
+AnalogIn v_out(p16);
+AnalogIn light_in(p15);
+
+
+    float r_temp, temp;
+    float vo,ax,ay,az, light; 
+    
+     void tos(){    
+                    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");
+                }
+           
+    void write(){
+            
+                    FILE*fp;
+                    fp = fopen("/local/CanSat.txt", "a");
+                    temp = temp_in;
+                    vo   = v_out/10*33;
+                    ax = acc_x/10;
+                    ay = acc_y/10;
+                    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");
+                    fclose(fp);
+                }
+
+int main() { 
+    
+
+                    
+               writeTimer.attach(&write,0.01);
+               writeTimer.attach(&tos,1.0);
+               
+               }
diff -r 000000000000 -r 6613b486c090 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Jul 21 13:26:58 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/b3110cd2dd17
\ No newline at end of file