Code controlling second MBED in speed detection system that plays speaker sounds and writes time stamp to microSD card. By Ibrahim Khan and Saad Khan.
Dependencies: SDFileSystem mbed wave_player
By Ibrahim Khan and Saad Khan. Part of ECE4180 project.
Revision 0:10686b395bb9, committed 2016-12-09
- Comitter:
- gotmilk
- Date:
- Fri Dec 09 07:41:53 2016 +0000
- Commit message:
- initial commit of code running on second mbed in speed detection system
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDFileSystem.lib Fri Dec 09 07:41:53 2016 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/mbed_official/code/SDFileSystem/#8db0d3b02cec
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Dec 09 07:41:53 2016 +0000 @@ -0,0 +1,42 @@ +#include "mbed.h" +#include "SDFileSystem.h" +#include "wave_player.h" + +DigitalIn fast(p9); +DigitalIn turn(p10); +SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card +AnalogOut DACout(p18); +wave_player waver(&DACout); + +int main() { + while(1) { + if (fast) { + time_t seconds = time(NULL); + FILE *wave_file; +// uLCD.cls(); + wave_file=fopen("/sd/fast.wav","r"); + waver.play(wave_file); + fclose(wave_file); + FILE *fp = fopen("/sd/speedlog.txt", "w"); + //if(fp == NULL) { + // uLCD.printf("Could not open file for write\n\r"); + //} + fprintf(fp, "Driver drove above limit on %s\n", ctime(&seconds)); + fclose(fp); + } + else if (turn) { + time_t seconds = time(NULL); + FILE *wave_file; + //uLCD.cls(); + wave_file=fopen("/sd/turn.wav","r"); + waver.play(wave_file); + fclose(wave_file); + FILE *fp = fopen("/sd/speedlog.txt", "w"); + //if(fp == NULL) { + // uLCD.printf("Could not open file for write\n"); + //} + fprintf(fp, "Driver turned above g-limit on on %s\n", ctime(&seconds)); + fclose(fp); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Dec 09 07:41:53 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9bcdf88f62b0 \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wave_player.lib Fri Dec 09 07:41:53 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/sravet/code/wave_player/#acc3e18e77ad