![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
mpu con sd card
Dependencies: mbed MPU6050 SDFileSystem ds3231
Revision 2:6aec5de30f86, committed 2020-05-25
- Comitter:
- SantiagoE
- Date:
- Mon May 25 23:07:31 2020 +0000
- Parent:
- 1:e4d7342be507
- Commit message:
- SDCARD_MPU6050
Changed in this revision
diff -r e4d7342be507 -r 6aec5de30f86 MPU6050.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MPU6050.lib Mon May 25 23:07:31 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/wisnup/code/MPU6050/#0e23b7f6dccd
diff -r e4d7342be507 -r 6aec5de30f86 ds3231.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ds3231.lib Mon May 25 23:07:31 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/Maxim-Integrated/code/ds3231/#11630748e2f2
diff -r e4d7342be507 -r 6aec5de30f86 main.cpp --- a/main.cpp Tue May 16 05:18:55 2017 +0000 +++ b/main.cpp Mon May 25 23:07:31 2020 +0000 @@ -1,19 +1,100 @@ + #include "mbed.h" #include "SDFileSystem.h" - -SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board - -int main() { +#include "MPU6050.h" +#include <string> +#include <stdio.h> +#include <stdlib.h> +#include <ds3231.h> +Ds3231 rtc (D14,D15); +//SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board //mosi, miso, sclk +MPU6050 Mpu (D7,D6); +SDFileSystem sd(D11, D12, D13, D8, "sd"); +Ticker timer; +string Vector[100]={"","","","","","","","","","", +"","","","","","","","","","", +"","","","","","","","","","", +"","","","","","","","","",""}; +/*"","","","","","","","","",""}; +"","","","","","","","","","", +"","","","","","","","","","", +"","","","","","","","","","", +"","","","","","","","","","", +"","","","","","","","","",""}; +*/ + + + + +int j=0; +//string d; + +int ax,ay,az; +float gx,gy,gz,gt; + +char a; +char buffer[50]; +int n,g=0; +Serial pc(USBTX, USBRX); +int main() +{ + ds3231_time_t time = {0,58,10,5,1}; //Los primeros 3 números corresponden a los segundos,minutos,horas //rtc + uint16_t rtn_val; + rtc.set_time(time); + + ds3231_calendar_t calendar = {28,9,25,8}; // Los primeros tres valores corresponden al día/mes/año //endrtc + +while(true) +{ + gx= Mpu.getGyroRawX(); + gx=gx/1000; + gy= Mpu.getGyroRawY(); + gy=gy/1000; + gz= Mpu.getGyroRawZ(); + gz=gz/1000; + + rtn_val = rtc.get_time(&time); //rtc + pc.printf("%d/%d/%d - ", calendar); + pc.printf("%d:%d:%d - ",time); //endrtc + + pc.printf("%d", gx); + pc.printf(","); + pc.printf("%d", gy); + pc.printf(","); + pc.printf("%d", gz); + pc.printf("\n\r"); + n=sprintf (buffer, "%f,%f,%f",gx,gy,gz); + Vector[j]=buffer; + j++; + if(j==40){ + j=0; + break; + } + wait(0.5); +} + + /*rtn_val = rtc.get_time(&time); //rtc + pc.printf("%d/%d/%d - ", calendar); + pc.printf("%d:%d:%d\n\r",time); //endrtc */ + printf("Hello World!\n"); mkdir("/sd/mydir", 0777); FILE *fp = fopen("/sd/mydir/sdtest.txt", "w"); - if(fp == NULL) { + if(fp == NULL) + { error("Could not open file for write\n"); } - fprintf(fp, "Hello fun SD Card World!"); + //le voy a mandar un audio explicandole que toca hacer paara que me entienda y ki hagamos entre los 2 hacele + + for (int i=0;i<40;i++) + { + fprintf(fp,"%s\n\r",Vector[i]); + fprintf(fp,"\n\r"); + } + //fprintf(fp, "Quiero pasar en este trabajo :c"); fclose(fp); - printf("Goodbye World!\n"); -} + +} \ No newline at end of file