private
Dependencies: ADXL345 FATFileSystem LPS331_SPI mbed
Revision 1:9dc9b228c5b7, committed 2016-09-22
- Comitter:
- obaratakahiro
- Date:
- Thu Sep 22 05:58:23 2016 +0000
- Parent:
- 0:e9f20ea63046
- Child:
- 2:6c4273f2f7ed
- Commit message:
- ????
Changed in this revision
| ADXL345.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ADXL345.lib Thu Sep 22 05:58:23 2016 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/aberk/code/ADXL345/#bd8f0f20f433
--- a/main.cpp Thu Sep 22 03:08:19 2016 +0000
+++ b/main.cpp Thu Sep 22 05:58:23 2016 +0000
@@ -1,30 +1,40 @@
#include "mbed.h"
#include "SDFileSystem.h"
#include "LPS331_SPI.h"
+#include "ADXL345.h"
DigitalOut myled(LED1);
LPS331_SPI press(dp2, dp1, dp6, dp26);
-SDFileSystem sd(dp2, dp1, dp6, dp17, "sd");
+SDFileSystem sd(dp2, dp1, dp6, dp17, "sd");
+AnalogIn sensor (dp4);
+ADXL345 accelerometer(dp2, dp1, dp6, dp25);
+Serial pc(USBTX, USBRX);
int main()
{
-
+ int readings[3] = {0, 0, 0};
+
+ accelerometer.setPowerControl(0x00);
+ accelerometer.setDataFormatControl(0x0B);
+ accelerometer.setDataRate(ADXL345_3200HZ);
+ accelerometer.setPowerControl(0x08);
press.quickStart();
int count;
-
+
while(1){
FILE *fp = fopen("/sd/sdtest.txt", "a");
if(fp == NULL) {
error("Could not open file for write\n");
}
-
+ float ain = sensor;
float pressure;
+ accelerometer.getOutput(readings);
pressure = press.getPressure();
+ ain = (ain * 3.3 - 0.6) / 0.01;
- count = fprintf(fp, "%f\r\n",pressure);
+ count = fprintf(fp,"%f\r\n%f\r\n%i\r\n%i\r\n%i\r\n",pressure,ain,(int16_t)readings[0], (int16_t)readings[1], (int16_t)readings[2]);
if ( count < 0 ) {
printf("ファイルの書込みに失敗しました.\n");
-
}
@@ -32,8 +42,4 @@
myled = !myled;
wait(0.5);
}
-
-
-
-
}