Not finished. This is my first attemp to make an autonomous vehicle for the Sparkfun Autonomous Competition (https://avc.sparkfun.com/) of June 2015.
Dependencies: FXOS8700CQ SDFileSystem mbed
Fork of AVC_Robot_Controled_Navigation by
- For my autonomous robot I will use a GPS, magnometer, accelerometer, and encoders.
- I control my robot with a remote control to save the GPS points (detect turns) using a xBee radio and save them to a file in a SD card.
my_libraries/sd_card.cpp@2:94059cb643be, 2014-10-16 (annotated)
- Committer:
- gerardo_carmona
- Date:
- Thu Oct 16 17:30:52 2014 +0000
- Revision:
- 2:94059cb643be
v1.2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gerardo_carmona | 2:94059cb643be | 1 | // ----- Libraries ------------------------------------------------------------------ |
gerardo_carmona | 2:94059cb643be | 2 | #include "mbed.h" |
gerardo_carmona | 2:94059cb643be | 3 | #include "sd_card.h" |
gerardo_carmona | 2:94059cb643be | 4 | |
gerardo_carmona | 2:94059cb643be | 5 | // ----- Constants ------------------------------------------------------------------ |
gerardo_carmona | 2:94059cb643be | 6 | |
gerardo_carmona | 2:94059cb643be | 7 | |
gerardo_carmona | 2:94059cb643be | 8 | // ----- I/O Pins ------------------------------------------------------------------- |
gerardo_carmona | 2:94059cb643be | 9 | SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd"); // MOSI, MISO, SCK, CS |
gerardo_carmona | 2:94059cb643be | 10 | |
gerardo_carmona | 2:94059cb643be | 11 | // ----- Others --------------------------------------------------------------------- |
gerardo_carmona | 2:94059cb643be | 12 | FILE *fp; |
gerardo_carmona | 2:94059cb643be | 13 | |
gerardo_carmona | 2:94059cb643be | 14 | // ----- Variables ------------------------------------------------------------------ |
gerardo_carmona | 2:94059cb643be | 15 | int lat_points[10], lon_points[10]; |
gerardo_carmona | 2:94059cb643be | 16 | int points_gps; |
gerardo_carmona | 2:94059cb643be | 17 | |
gerardo_carmona | 2:94059cb643be | 18 | |
gerardo_carmona | 2:94059cb643be | 19 | // ----- Functions ------------------------------------------------------------------ |
gerardo_carmona | 2:94059cb643be | 20 | void savefile_sd(){ |
gerardo_carmona | 2:94059cb643be | 21 | FILE *fp = fopen("/sd/gps_points.txt", "w"); |
gerardo_carmona | 2:94059cb643be | 22 | if (fp == 0){ |
gerardo_carmona | 2:94059cb643be | 23 | //printf("Could not open file\n"); |
gerardo_carmona | 2:94059cb643be | 24 | }else{ |
gerardo_carmona | 2:94059cb643be | 25 | for (int i = 0; i < points_gps; i++){ |
gerardo_carmona | 2:94059cb643be | 26 | fprintf(fp, "%f\t%f", lat_points[i], lon_points[i]); |
gerardo_carmona | 2:94059cb643be | 27 | fprintf(fp, "\r\n"); |
gerardo_carmona | 2:94059cb643be | 28 | } |
gerardo_carmona | 2:94059cb643be | 29 | } |
gerardo_carmona | 2:94059cb643be | 30 | fclose(fp); |
gerardo_carmona | 2:94059cb643be | 31 | } |
gerardo_carmona | 2:94059cb643be | 32 |