final design project

Dependencies:   SDFileSystem TextLCD mbed wave_player

Committer:
lenhardt
Date:
Thu Nov 20 22:36:06 2014 +0000
Revision:
0:462dcb4093f2
guccimaynepradamayneversace

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lenhardt 0:462dcb4093f2 1 #include "mbed.h"
lenhardt 0:462dcb4093f2 2 #include "SDFileSystem.h"
lenhardt 0:462dcb4093f2 3 #include "wave_player.h"
lenhardt 0:462dcb4093f2 4
lenhardt 0:462dcb4093f2 5 SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card
lenhardt 0:462dcb4093f2 6
lenhardt 0:462dcb4093f2 7 Ticker tick;
lenhardt 0:462dcb4093f2 8
lenhardt 0:462dcb4093f2 9 AnalogIn fsr(p15);
lenhardt 0:462dcb4093f2 10 PwmOut led(p26);
lenhardt 0:462dcb4093f2 11 Serial term(USBTX, USBRX);
lenhardt 0:462dcb4093f2 12 AnalogOut DACout(p18);
lenhardt 0:462dcb4093f2 13
lenhardt 0:462dcb4093f2 14 wave_player waver(&DACout);
lenhardt 0:462dcb4093f2 15 FILE *wave_file;
lenhardt 0:462dcb4093f2 16
lenhardt 0:462dcb4093f2 17 void playthisbitch() {
lenhardt 0:462dcb4093f2 18 //FILE *wave_file;
lenhardt 0:462dcb4093f2 19 //wave_file=fopen("/sd/sample.wav","r");
lenhardt 0:462dcb4093f2 20 //waver.play(wave_file);
lenhardt 0:462dcb4093f2 21 }
lenhardt 0:462dcb4093f2 22
lenhardt 0:462dcb4093f2 23 int main() {
lenhardt 0:462dcb4093f2 24 //FILE *wave_file;
lenhardt 0:462dcb4093f2 25 //wave_file=fopen("/sd/sample.wav","r");
lenhardt 0:462dcb4093f2 26 //waver.play(wave_file);
lenhardt 0:462dcb4093f2 27
lenhardt 0:462dcb4093f2 28
lenhardt 0:462dcb4093f2 29 float reading;
lenhardt 0:462dcb4093f2 30 while (1){
lenhardt 0:462dcb4093f2 31 reading = (float)fsr;
lenhardt 0:462dcb4093f2 32 term.printf("\nReading is: %f\r", (float)fsr);
lenhardt 0:462dcb4093f2 33 led = 0.0f;
lenhardt 0:462dcb4093f2 34 led = (float)fsr;
lenhardt 0:462dcb4093f2 35 wait(.1);
lenhardt 0:462dcb4093f2 36 if( (float)fsr > .02){
lenhardt 0:462dcb4093f2 37 //tick.detach();
lenhardt 0:462dcb4093f2 38 //tick.attach(&playthisbitch, 500000);
lenhardt 0:462dcb4093f2 39 //tick.detach();
lenhardt 0:462dcb4093f2 40 wave_file=fopen("/sd/sample.wav","r");
lenhardt 0:462dcb4093f2 41 waver.play(wave_file);
lenhardt 0:462dcb4093f2 42 }
lenhardt 0:462dcb4093f2 43 wait_us(500);
lenhardt 0:462dcb4093f2 44 }
lenhardt 0:462dcb4093f2 45
lenhardt 0:462dcb4093f2 46 fclose(wave_file);
lenhardt 0:462dcb4093f2 47 }
lenhardt 0:462dcb4093f2 48 /*
lenhardt 0:462dcb4093f2 49 #include "mbed.h"
lenhardt 0:462dcb4093f2 50 #include "SDFileSystem.h"
lenhardt 0:462dcb4093f2 51 #include "wave_player.h"
lenhardt 0:462dcb4093f2 52
lenhardt 0:462dcb4093f2 53
lenhardt 0:462dcb4093f2 54 SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card
lenhardt 0:462dcb4093f2 55
lenhardt 0:462dcb4093f2 56 AnalogOut DACout(p18);
lenhardt 0:462dcb4093f2 57
lenhardt 0:462dcb4093f2 58 wave_player waver(&DACout);
lenhardt 0:462dcb4093f2 59
lenhardt 0:462dcb4093f2 60 int main()
lenhardt 0:462dcb4093f2 61 {
lenhardt 0:462dcb4093f2 62 FILE *wave_file;
lenhardt 0:462dcb4093f2 63 printf("\n\n\nHello, wave world!\n");
lenhardt 0:462dcb4093f2 64 wave_file=fopen("/sd/sample.wav","r");
lenhardt 0:462dcb4093f2 65 waver.play(wave_file);
lenhardt 0:462dcb4093f2 66 fclose(wave_file);
lenhardt 0:462dcb4093f2 67 }*/